1 | #! perl # mandatory |
1 | #! perl # mandatory |
2 | |
2 | |
3 | # player scheduler, evoking players from ram |
3 | # player scheduler, evoking players from ram |
4 | |
4 | |
5 | our $SCHEDULE_INTERVAL = $cf::CFG{player_schedule_interval} || 10; # time the player scheduler sleeps between runs |
5 | CONF SCHEDULE_INTERVAL : player_schedule_interval = 10; # time the player scheduler sleeps between runs |
6 | our $SAVE_TIMEOUT = $cf::CFG{player_save_interval} || 20; # save players every n seconds |
6 | CONF SAVE_TIMEOUT : player_save_interval = 20; # save players every n seconds |
7 | |
7 | |
8 | our $SCHEDULER = cf::async_ext { |
8 | our $SCHEDULER = cf::async_ext { |
9 | $Coro::current->{desc} = "player scheduler"; |
9 | $Coro::current->{desc} = "player scheduler"; |
10 | |
10 | |
11 | while () { |
11 | while () { |
12 | Coro::EV::timer_once $SCHEDULE_INTERVAL; |
12 | Coro::AnyEvent::sleep $SCHEDULE_INTERVAL; |
13 | |
13 | |
14 | # this weird form of iteration over values is used because |
14 | # this weird form of iteration over values is used because |
15 | # the hash changes underneath us frequently, and for |
15 | # the hash changes underneath us frequently, and for |
16 | # keeps a direct reference to the value without (in 5.8 perls) |
16 | # keeps a direct reference to the value without (in 5.8 perls) |
17 | # keeping a reference, so this is prone to crashes or worse. |
17 | # keeping a reference, so this is prone to crashes or worse. |