--- deliantra/server/lib/cf.pm 2007/01/05 19:12:03 1.139 +++ deliantra/server/lib/cf.pm 2007/01/05 20:04:02 1.140 @@ -231,6 +231,16 @@ $guard } +=item cf::async { BLOCK } + +Currently the same as Coro::async_pool, meaning you cannot use +C, C or other gimmicks on these coroutines. The only +thing you are allowed to do is call C on it. + +=cut + +BEGIN { *async = \&Coro::async_pool } + =item cf::sync_job { BLOCK } The design of crossfire+ requires that the main coro ($Coro::main) is @@ -258,7 +268,7 @@ my $busy = 1; my @res; - (Coro::async_pool { + (async { @res = eval { $job->() }; warn $@ if $@; undef $busy; @@ -279,17 +289,17 @@ } } -=item $coro = cf::coro { BLOCK } +=item $coro = cf::async_ext { BLOCK } -Creates (and readies) and returns a new coro. This coro is automcatially -being canceled when the extension calling this is being unloaded. +Like async, but this coro is automcatially being canceled when the +extension calling this is being unloaded. =cut -sub coro(&) { +sub async_ext(&) { my $cb = shift; - my $coro = &Coro::async_pool ($cb); + my $coro = &Coro::async ($cb); $coro->on_destroy (sub { delete $EXT_CORO{$coro+0}; @@ -1272,10 +1282,7 @@ sub find_sync { my ($path, $origin) = @_; - cf::sync_job { - my $map = cf::map::find $path, $origin; - $map - } + cf::sync_job { cf::map::find $path, $origin } } sub do_load_sync { @@ -1547,9 +1554,13 @@ if ($pl->ob->{_link_pos}) { $pl->ob->enter_link; - (Coro::async_pool { + (async { # we need this sleep as the login has a concurrent enter_exit running # and this sleep increases chances of the player not ending up in scorn + $pl->ob->reply (undef, + "There was an internal problem at your last logout, " + . "the server will try to bring you to your intended destination in a second.", + cf::NDI_RED); Coro::Timer::sleep 1; $pl->ob->leave_link; })->prio (2); @@ -1566,7 +1577,7 @@ $self->enter_link; - (Coro::async_pool { + (async { $path = new cf::path $path; my $map = cf::map::find $path->as_string; @@ -1638,7 +1649,7 @@ $self->enter_link; - (Coro::async_pool { + (async { $self->deactivate_recursive; # just to be sure unless (eval { prepare_random_map $exit @@ -1729,7 +1740,7 @@ }, ); -=item $client->coro (\&cb) +=item $client->async (\&cb) Create a new coroutine, running the specified callback. The coroutine will be automatically cancelled when the client gets destroyed (e.g. on logout, @@ -1737,10 +1748,10 @@ =cut -sub cf::client::coro { +sub cf::client::async { my ($self, $cb) = @_; - my $coro = &Coro::async_pool ($cb); + my $coro = &Coro::async ($cb); $coro->on_destroy (sub { delete $self->{_coro}{$coro+0}; @@ -2004,7 +2015,7 @@ # we must not ever block the main coroutine local $Coro::idle = sub { Carp::cluck "FATAL: Coro::idle was called, major BUG, use cf::sync_job!\n";#d# - Coro::async_pool { Event::one_event }; + async { Event::one_event }; }; cfg_load;