Coro
view release on metacpan or search on metacpan
make it compile with perl 5.8.6 (yes, apple apparently loves
outdated software). Reported by John S.
4.744 Tue Jul 8 22:06:35 CEST 2008
- correctly provide default DIE/WARN handlers as documented.
- also overwrite PL_vtbl_sigelem.svt_clear, even though current
implementations inside perl work fine for us.
4.743 Mon Jun 16 00:21:57 CEST 2008
- when using Coro::EV without running EV::loop it could
result in busy-waiting for events, this has been fixed.
- reduce codesize and improve performance by using EV_DEFAULT_UC.
4.742 Sat May 31 14:10:21 CEST 2008
- implement a workaround for (some) perl <5.8.8 versions.
- require EV 3.3+.
4.741 Fri May 30 23:33:09 CEST 2008
- tell netbsd how utterly broken their imitation of an OS is
and refuse to build by default if pthreads are in use.
- switch to "s" method on all bsd's by default, as their ucontext
Coro/AnyEvent.pm view on Meta::CPAN
use Coro;
use AnyEvent;
# using both Coro and AnyEvent will automatically load Coro::AnyEvent
# or load it manually for its utility functions:
use Coro::AnyEvent;
Coro::AnyEvent::sleep 5; # block current thread for 5s
Coro::AnyEvent::poll; # poll for new events once
Coro::AnyEvent::idle; # block until process no longer busy
Coro::AnyEvent::idle_upto 5; # same, but only up to 5 seconds
Coro::AnyEvent::readable $fh, 60
or die "fh didn't become readable within 60 seconds\n";
=head1 DESCRIPTION
When one naively starts to use threads in Perl, one will quickly run
into the problem that threads which block on a syscall (sleeping,
reading from a socket etc.) will block all threads.
Coro/AnyEvent.pm view on Meta::CPAN
events. Unlike C<poll>, it will only resume the thread once there are no
events to handle anymore, i.e. when the process is otherwise idle.
This is good for background threads that shouldn't use CPU time when
foreground jobs are ready to run.
=item Coro::AnyEvent::idle_upto $seconds
Like C<idle>, but with a maximum waiting time.
If your process is busy handling events, calling C<idle> can mean that
your thread will never be resumed. To avoid this, you can use C<idle_upto>
and specify a timeout, after which your thread will be resumed even if the
process is completely busy.
=item Coro::AnyEvent::readable $fh_or_fileno[, $timeout]
=item Coro::AnyEvent::writable $fh_or_fileno[, $timeout]
Blocks the current thread until the given file handle (or file descriptor)
becomes readable (or writable), or the given timeout has elapsed,
whichever happens first. No timeout counts as infinite timeout.
Returns true when the file handle became ready, false when a timeout
Coro/State.xs view on Meta::CPAN
if (items <= 0)
croak ("Coro::cancel called without coro object,");
coro = SvSTATE (arg [0]);
coro_hv = coro->hv;
coro_set_status (aTHX_ coro, arg + 1, items - 1);
if (ecb_expect_false (coro->flags & CF_NOCANCEL))
{
/* coro currently busy cancelling something, so just notify it */
coro->slf_frame.data = (void *)coro;
frame->prepare = prepare_nop;
frame->check = slf_check_nop;
}
else if (coro_hv == (HV *)SvRV (coro_current))
{
/* cancelling the current coro is allowed, and equals terminate */
slf_init_terminate_cancel_common (aTHX_ frame, coro_hv);
}
Coro/State.xs view on Meta::CPAN
* this is ugly, and hopefully fully worth the extra speed.
* besides, I can't get the slow-but-safe version working...
*/
slf_frame.data = 0;
self->flags |= CF_NOCANCEL;
coro_state_destroy (aTHX_ coro);
self->flags &= ~CF_NOCANCEL;
if (slf_frame.data)
{
/* while we were busy we have been cancelled, so terminate */
slf_init_terminate_cancel_common (aTHX_ frame, self->hv);
}
else
{
frame->prepare = prepare_nop;
frame->check = slf_check_nop;
}
}
}
( run in 0.330 second using v1.01-cache-2.11-cpan-87723dcf8b7 )