ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/lib/cf.pm
(Generate patch)

Comparing deliantra/server/lib/cf.pm (file contents):
Revision 1.457 by root, Wed Oct 1 05:50:19 2008 UTC vs.
Revision 1.458 by root, Sat Dec 13 20:34:37 2008 UTC

32use Opcode; 32use Opcode;
33use Safe; 33use Safe;
34use Safe::Hole; 34use Safe::Hole;
35use Storable (); 35use Storable ();
36 36
37use Guard ();
37use Coro (); 38use Coro ();
38use Coro::State; 39use Coro::State;
39use Coro::Handle; 40use Coro::Handle;
40use Coro::EV; 41use Coro::EV;
41use Coro::AnyEvent; 42use Coro::AnyEvent;
330Wait until the given lock is available. See cf::lock_acquire. 331Wait until the given lock is available. See cf::lock_acquire.
331 332
332=item my $lock = cf::lock_acquire $string 333=item my $lock = cf::lock_acquire $string
333 334
334Wait until the given lock is available and then acquires it and returns 335Wait until the given lock is available and then acquires it and returns
335a Coro::guard object. If the guard object gets destroyed (goes out of scope, 336a L<Guard> object. If the guard object gets destroyed (goes out of scope,
336for example when the coroutine gets canceled), the lock is automatically 337for example when the coroutine gets canceled), the lock is automatically
337returned. 338returned.
338 339
339Locks are *not* recursive, locking from the same coro twice results in a 340Locks are *not* recursive, locking from the same coro twice results in a
340deadlocked coro. 341deadlocked coro.
374 lock_wait $key; 375 lock_wait $key;
375 376
376 $LOCK{$key} = []; 377 $LOCK{$key} = [];
377 $LOCKER{$key} = $Coro::current;#d# 378 $LOCKER{$key} = $Coro::current;#d#
378 379
379 Coro::guard { 380 Guard::guard {
380 delete $LOCKER{$key};#d# 381 delete $LOCKER{$key};#d#
381 # wake up all waiters, to be on the safe side 382 # wake up all waiters, to be on the safe side
382 $_->ready for @{ delete $LOCK{$key} }; 383 $_->ready for @{ delete $LOCK{$key} };
383 } 384 }
384} 385}
390} 391}
391 392
392sub freeze_mainloop { 393sub freeze_mainloop {
393 tick_inhibit_inc; 394 tick_inhibit_inc;
394 395
395 Coro::guard \&tick_inhibit_dec; 396 &Guard::guard (\&tick_inhibit_dec);
396} 397}
397 398
398=item cf::periodic $interval, $cb 399=item cf::periodic $interval, $cb
399 400
400Like EV::periodic, but randomly selects a starting point so that the actions 401Like EV::periodic, but randomly selects a starting point so that the actions

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines