… | |
… | |
53 | }; |
53 | }; |
54 | |
54 | |
55 | our $SCHEDULER = cf::async_ext { |
55 | our $SCHEDULER = cf::async_ext { |
56 | $Coro::current->{desc} = "map scheduler"; |
56 | $Coro::current->{desc} = "map scheduler"; |
57 | $Coro::current->prio (Coro::PRIO_MAX); |
57 | $Coro::current->prio (Coro::PRIO_MAX); |
58 | my $timer = Coro::Event->timer (data => cf::WF_AUTOCANCEL); |
|
|
59 | |
58 | |
60 | while () { |
59 | while () { |
61 | if ($cf::LOADAVG > $SWAP_LOAD2) { |
60 | if ($cf::LOADAVG > $SWAP_LOAD2) { |
62 | $timer->interval (0.05); |
61 | Coro::EV::timer_once 0.05; |
63 | $timer->next; |
|
|
64 | cf::wait_for_tick; |
62 | cf::wait_for_tick; |
65 | } else { |
63 | } else { |
66 | $timer->interval ($SCHEDULE_INTERVAL); |
64 | Coro::EV::timer_once $SCHEDULE_INTERVAL; |
67 | $timer->next; |
|
|
68 | } |
65 | } |
69 | |
66 | |
70 | # this weird form of iteration over values is used because |
67 | # this weird form of iteration over values is used because |
71 | # the hash changes underneath us frequently, and for |
68 | # the hash changes underneath us frequently, and for |
72 | # keeps a direct reference to the value without (in 5.8 perls) |
69 | # keeps a direct reference to the value without (in 5.8 perls) |