--- deliantra/server/lib/cf.pm 2006/08/12 11:51:37 1.30 +++ deliantra/server/lib/cf.pm 2006/08/15 18:07:25 1.32 @@ -7,6 +7,7 @@ use Safe; use Safe::Hole; +use Time::HiRes; use Event; $Event::Eval = 1; # no idea why this is required, but it is @@ -183,10 +184,6 @@ warn "removing extension $pkg\n"; - if (my $cb = $pkg->can ("on_unload")) { - $cb->($pkg); - } - # remove hooks for my $idx (0 .. $#EVENT) { delete $hook[$idx]{$pkg}; @@ -210,6 +207,13 @@ delete $extcmd{$name}; } + if (my $cb = $pkg->can ("on_unload")) { + eval { + $cb->($pkg); + 1 + } or warn "$pkg unloaded, but with errors: $@"; + } + Symbol::delete_package $pkg; } @@ -405,6 +409,18 @@ ############################################################################# # core extensions - in perl +my $delta_timer = Event->timer ( + parked => 1, + prio => Event::PRIO_HIGH, + cb => sub { Event::unloop (undef) }, +); + +sub sleep_delta($) { + $delta_timer->at (Event::time + $_[0]); + $delta_timer->start; + Event::loop; +} + =item cf::player::exists $login Returns true when the given account exists.