--- deliantra/server/lib/cf.pm 2007/01/04 17:28:49 1.134 +++ deliantra/server/lib/cf.pm 2007/01/04 20:29:46 1.135 @@ -181,28 +181,6 @@ JSON::Syck::Dump $_[0] } -=item my $guard = cf::guard { BLOCK } - -Run the given callback when the guard object gets destroyed (useful for -coroutine cancellations). - -You can call C<< ->cancel >> on the guard object to stop the block from -being executed. - -=cut - -sub guard(&) { - bless \(my $cb = $_[0]), cf::guard::; -} - -sub cf::guard::cancel { - ${$_[0]} = sub { }; -} - -sub cf::guard::DESTROY { - ${$_[0]}->(); -} - =item cf::lock_wait $string Wait until the given lock is available. See cf::lock_acquire. @@ -210,7 +188,7 @@ =item my $lock = cf::lock_acquire $string Wait until the given lock is available and then acquires it and returns -a guard object. If the guard object gets destroyed (goes out of scope, +a Coro::guard object. If the guard object gets destroyed (goes out of scope, for example when the coroutine gets canceled), the lock is automatically returned. @@ -239,7 +217,7 @@ $LOCK{$key} = []; - cf::guard { + Coro::guard { # wake up all waiters, to be on the safe side $_->ready for @{ delete $LOCK{$key} }; } @@ -264,7 +242,7 @@ sub freeze_mainloop { return unless $TICK_WATCHER->is_active; - my $guard = guard { $TICK_WATCHER->start }; + my $guard = Coro::guard { $TICK_WATCHER->start }; $TICK_WATCHER->stop; $guard } @@ -1186,6 +1164,9 @@ my $map = cf::map::new or return; + # for better error messages only, will be overwritten + $map->path ($path); + $map->load_header ($path) or return;