ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/maps/perl/map-prefetch.ext
(Generate patch)

Comparing deliantra/maps/perl/map-prefetch.ext (file contents):
Revision 1.9 by root, Wed Aug 2 11:17:08 2006 UTC vs.
Revision 1.12 by root, Sun Aug 27 15:23:30 2006 UTC

2 2
3# this plug-in prefetches maps. everytime a player enters a map, 3# this plug-in prefetches maps. everytime a player enters a map,
4# it will asynchronously prefetch files from disk (it will not load them 4# it will asynchronously prefetch files from disk (it will not load them
5# into the server, but into the OS cache only). 5# into the server, but into the OS cache only).
6 6
7if (0) { #test#
8use Errno (); 7use Errno ();
9use Time::HiRes; 8use Time::HiRes;
10use Fcntl; 9use Fcntl;
11use IO::AIO; 10use IO::AIO;
12 11
111 110
112 my $exit = $MAP_EXITS{$map->path} ||= find_exits $map; 111 my $exit = $MAP_EXITS{$map->path} ||= find_exits $map;
113 prefetch map => $_ for @$exit; 112 prefetch map => $_ for @$exit;
114} 113}
115 114
116sub on_mapenter { 115cf::attach_to_players prio => -900,
117 my ($ob) = @_; 116 on_map_change => sub {
117 my ($pl, $old, $new) = @_;
118 118
119 prefetch_map $ob->map; 119 prefetch_map $new;
120} 120 },
121;
121 122
123if (0) { #test#
122# prefetch a few players/second 124# prefetch a few players/second
123{ 125{
124 my @players; 126 my @players;
125 127
126 Event->timer (interval => 0.2, cb => sub { 128 Event->timer (interval => 0.2, cb => sub {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines