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

Comparing deliantra/server/ext/map-scheduler.ext (file contents):
Revision 1.8 by root, Wed Jan 3 03:04:12 2007 UTC vs.
Revision 1.11 by root, Thu Jan 4 16:19:32 2007 UTC

2 2
3# this extension swaps out maps and resets them, in essence managing 3# this extension swaps out maps and resets them, in essence managing
4# the reset/swap policy of the server. 4# the reset/swap policy of the server.
5 5
6our $DEACTIVATE_TIMEOUT = 20; # number of seconds after which maps get deactivated to save cpu 6our $DEACTIVATE_TIMEOUT = 20; # number of seconds after which maps get deactivated to save cpu
7our $SWAP_TIMEOUT = 50; # number of seconds after which maps inactive get swapped out 7our $SWAP_TIMEOUT = 35; # number of seconds after which maps inactive get swapped out
8our $SCHEDULE_INTERVAL = 2; # time the map scheduler sleeps between runs 8our $SCHEDULE_INTERVAL = 2; # time the map scheduler sleeps between runs
9our $SAVE_TIMEOUT = 30; # save maps every n seconds 9our $SAVE_TIMEOUT = 20; # save maps every n seconds
10our $SAVE_INTERVAL = 0.3; # save at max. one map every $SAVE_INTERVAL 10our $SAVE_INTERVAL = 0.1; # save at max. one map every $SAVE_INTERVAL
11 11
12our $SCHEDULER = cf::coro { 12our $SCHEDULER = cf::coro {
13 while () { 13 while () {
14 Coro::Timer::sleep $SCHEDULE_INTERVAL; 14 Coro::Timer::sleep $SCHEDULE_INTERVAL;
15 15
16 # this weird form of iteration over values is used because
17 # the hash changes underneath us frequently, and for
18 # keeps a direct reference to the value without (in 5.8 perls)
19 # keeping a reference, so this is prone to crashes or worse.
16 my @maps = keys %cf::MAP; 20 my @maps = keys %cf::MAP;
17 for (@maps) { 21 for (@maps) {
18 my $map = $cf::MAP{$_} 22 my $map = $cf::MAP{$_}
19 or next; 23 or next;
20 $map->valid or next; 24 $map->valid or next;
25
21 eval { 26 eval {
22 # not yet, because maps might become visible to players nearby 27 # not yet, because maps might become visible to players nearby
23 # we need to remove the map from %cf::MAP and all tiled map links 28 # we need to remove the map from %cf::MAP and all tiled map links
24# if ($last_access + $DEACTIVATE_TIMEOUT <= $cf::RUNTIME) { 29# if ($last_access + $DEACTIVATE_TIMEOUT <= $cf::RUNTIME) {
25# $map->deactivate; 30# $map->deactivate;
43 } 48 }
44}; 49};
45 50
46$SCHEDULER->prio (-2); 51$SCHEDULER->prio (-2);
47 52
53# map load prefetch
54cf::map->attach (
55 on_enter => sub {
56 my ($map, $pl) = @_;
57
58 # floodfill surrounging maps, asynchronously
59 },
60);
61

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines