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.8 by root, Sun Jul 16 19:14:10 2006 UTC vs.
Revision 1.14 by root, Tue Nov 7 15:04:44 2006 UTC

6 6
7use Errno (); 7use Errno ();
8use Time::HiRes; 8use Time::HiRes;
9use Fcntl; 9use Fcntl;
10use IO::AIO; 10use IO::AIO;
11
12Event->io (fd => IO::AIO::poll_fileno,
13 poll => 'r',
14 cb => \&IO::AIO::poll_cb);
15 11
16# find all potential exit paths, this is slow, so this info is cached 12# find all potential exit paths, this is slow, so this info is cached
17sub find_exits { 13sub find_exits {
18 my ($map) = @_; 14 my ($map) = @_;
19 15
110 106
111 my $exit = $MAP_EXITS{$map->path} ||= find_exits $map; 107 my $exit = $MAP_EXITS{$map->path} ||= find_exits $map;
112 prefetch map => $_ for @$exit; 108 prefetch map => $_ for @$exit;
113} 109}
114 110
115sub on_mapenter { 111cf::attach_to_players prio => -900,
116 my ($ob) = @_; 112 on_map_change => sub {
113 my ($pl, $new, $x, $x) = @_;
117 114
118 prefetch_map $ob->map; 115 prefetch_map $new;
119} 116 },
117;
120 118
119if (0) { #test#
121# prefetch a few players/second 120# prefetch a few players/second
122{ 121{
123 my @players; 122 my @players;
124 123
125 Event->timer (interval => 0.2, cb => sub { 124 Event->timer (interval => 0.2, cb => sub {
149 }; 148 };
150 149
151 $prefetch->(); $prefetch->(); 150 $prefetch->(); $prefetch->();
152 }; 151 };
153}); 152});
153}
154 154
155 155
156 156

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines