EV
view release on metacpan or search on metacpan
- add $timer->remaining.
- add EV::loop_depth.
- (libev) calling unloop in fork/prepare watchers will no longer poll
for new events.
- (libev) use GetSystemTimeAsFileTime instead of _timeb on windows,
for slightly higher accuracy.
- (libev) actually 0-initialise struct sigaction when installing
signals.
3.6 Tue Apr 28 02:50:37 CEST 2009
- keepalive(0) could decrease the refcount of the loop
permanently.
- add ev_suspend/ev_resume, also make ev_now_update
accessible via the XS API.
- most EV::<eventtype> constants were missing and have been
added :/.
- add EV::VERSION_MAJOR/VERSION_MINOR constants.
- (libev) multiple timers becoming ready within an event loop
iteration will be invoked in the "correct" order now.
- (libev) do not leave the event loop early just because we have
no active watchers, fixing a problem when embedding a kqueue
loop that has active kernel events but no registered watchers
(reported by blacksand blacksand).
- (libev) correctly zero the idx values for arrays, so destroying
and reinitialising the default loop actually works (patch by
Malek Hadj-Ali).
- (libev) new EV::CUSTOM revents flag for use by applications.
- (libev) add documentation section about priorites.
- (libev) add a glossary to the dcoumentation.
- (libev) extend the ev_fork description slightly.
- (libev) optimize a jump out of call_pending.
- t/03_keepalive could fail when there was no actual error.
3.53 Sun Feb 15 02:38:20 CET 2009
- (libev) on win32, the event loop creation could randomly fail
due to an initialised variable having the wrong value.
- (libev) probe for CLOCK_REALTIME support at runtime as well and
fall back to gettimeofday if there is an error, to support older
operating systems with newer header files/libraries.
- prefer gettimeofday over clock_gettime by default.
3.52 Wed Jan 7 21:46:14 CET 2009
1.5 Wed Nov 28 20:19:09 CET 2007
- add inotify backend.
- make testsuite even less sensible to timing issues,
add more stat tests.
- add ->attr, ->prev, ->stat calls to stat watcher.
1.4 Tue Nov 27 17:35:27 CET 2007
- work around a linux 2.4 kernel bug in child handlers.
- implement stat watcher interface.
- implement fork watcher interface.
- io->set did not keep the fh alive.
- actively check signal numbers/names to be valid.
- cleanups, minor fixes, new bugs.
- work around windows bugs in the testsuite.
1.3 Sun Nov 25 10:46:57 CET 2007
- stopping idle/check/prepare watchers could cause data corruption.
- implement and document EV::once.
- improved documentation, verify that netbsd indeed has the only
working kqueue implementation (out of darwin, freebsd, netbsd and
openbsd). Praise them!
- fix the data method so it might work.
- expose ev_ref/ev_unref to the C API.
- expose ref/unref in form of the ->keepalive method to perl.
- minor bugfixes and portability fixes.
1.2 Thu Nov 22 05:44:09 CET 2007
- disable kqueue by default on !netbsd, as its broken on freebsd,
darwin and openbsd and thus almost everywhere.
- add some allowance in t/01_timer.t for the uneven monotonic
vs. realtime clock tick on at least freebsd.
- add -lsocket -lnsl on solaris in case the perl guy forgot to
configure them.
Returns an integer describing the backend used by libev (EV::BACKEND_SELECT
or EV::BACKEND_EPOLL).
=item $active = EV::run [$flags]
=item $active = $loop->run ([$flags])
Begin checking for events and calling callbacks. It returns when a
callback calls EV::break or the flags are nonzero (in which case the
return value is true) or when there are no active watchers which reference
the loop (keepalive is true), in which case the return value will be
false. The return value can generally be interpreted as "if true, there is
more work left to do".
The $flags argument can be one of the following:
0 as above
EV::RUN_ONCE block at most once (wait, but do not loop)
EV::RUN_NOWAIT do not block at all (fetch/handle events but do not wait)
=item EV::break [$how]
Feed some events on this watcher into EV. EV will react to this call as if
the watcher had received the given C<$revents> mask.
=item $revents = $w->clear_pending
If the watcher is pending, this function clears its pending status and
returns its C<$revents> bitset (as if its callback was invoked). If the
watcher isn't pending it does nothing and returns C<0>.
=item $previous_state = $w->keepalive ($bool)
Normally, C<EV::run> will return when there are no active watchers
(which is a "deadlock" because no progress can be made anymore). This is
convenient because it allows you to start your watchers (and your jobs),
call C<EV::run> once and when it returns you know that all your jobs are
finished (or they forgot to register some watchers for their task :).
Sometimes, however, this gets in your way, for example when the module
that calls C<EV::run> (usually the main program) is not the same module
as a long-living watcher (for example a DNS client module written by
somebody else even). Then you might want any outstanding requests to be
handled, but you would not want to keep C<EV::run> from returning just
because you happen to have this long-running UDP port watcher.
In this case you can clear the keepalive status, which means that even
though your watcher is active, it won't keep C<EV::run> from returning.
The initial value for keepalive is true (enabled), and you can change it
any time.
Example: Register an I/O watcher for some UDP socket but do not keep the
event loop from running just because of that watcher.
my $udp_socket = ...
my $udp_watcher = EV::io $udp_socket, EV::READ, sub { ... };
$udp_watcher->keepalive (0);
=item $loop = $w->loop
Return the loop that this watcher is attached to.
=back
=head1 WATCHER TYPES
=over 4
=item $w = EV::io $fileno_or_fh, $eventmask, $callback
=item $w = EV::io_ns $fileno_or_fh, $eventmask, $callback
=item $w = $loop->io ($fileno_or_fh, $eventmask, $callback)
=item $w = $loop->io_ns ($fileno_or_fh, $eventmask, $callback)
As long as the returned watcher object is alive, call the C<$callback>
when at least one of events specified in C<$eventmask> occurs.
The $eventmask can be one or more of these constants ORed together:
EV::READ wait until read() wouldn't block anymore
EV::WRITE wait until write() wouldn't block anymore
The C<io_ns> variant doesn't start (activate) the newly created watcher.
=item $w->set ($fileno_or_fh, $eventmask)
OUTPUT:
RETVAL
#if CLEANUP_ENABLED
ev_cleanup *cleanup (SV *cb)
ALIAS:
cleanup_ns = 1
CODE:
RETVAL = e_new (sizeof (ev_cleanup), cb, default_loop_sv);
SvREFCNT_dec (RETVAL->loop); /* must not keep loop object alive */
ev_cleanup_set (RETVAL);
if (!ix) START (cleanup, RETVAL);
OUTPUT:
RETVAL
#endif
ev_child *child (int pid, int trace, SV *cb)
ALIAS:
child_ns = 1
void ev_invoke (ev_watcher *w, int revents = EV_NONE)
C_ARGS: e_loop (w), w, revents
int ev_clear_pending (ev_watcher *w)
C_ARGS: e_loop (w), w
void ev_feed_event (ev_watcher *w, int revents = EV_NONE)
C_ARGS: e_loop (w), w, revents
int keepalive (ev_watcher *w, SV *new_value = NO_INIT)
CODE:
{
RETVAL = w->e_flags & WFLAG_KEEPALIVE;
if (items > 1)
{
int value = SvTRUE (new_value) ? WFLAG_KEEPALIVE : 0;
if ((value ^ w->e_flags) & WFLAG_KEEPALIVE)
{
void ev_cleanup_stop (ev_cleanup *w)
CODE:
STOP (cleanup, w);
void DESTROY (ev_cleanup *w)
CODE:
STOP (cleanup, w);
SvREFCNT_inc (w->loop); /* has been dec'ed on creation */
e_destroy (w);
int keepalive (ev_watcher *w, SV *new_value = 0)
CODE:
RETVAL = 1;
OUTPUT:
RETVAL
#endif
MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_
#if EV_CHILD_ENABLE
OUTPUT:
RETVAL
#if CLEANUP_ENABLED
ev_cleanup *cleanup (struct ev_loop *loop, SV *cb)
ALIAS:
cleanup_ns = 1
CODE:
RETVAL = e_new (sizeof (ev_cleanup), cb, ST (0));
SvREFCNT_dec (RETVAL->loop); /* must not keep loop object alive */
ev_cleanup_set (RETVAL);
if (!ix) START (cleanup, RETVAL);
OUTPUT:
RETVAL
#endif
ev_child *child (struct ev_loop *loop, int pid, int trace, SV *cb)
ALIAS:
child_ns = 1
schmorp.h
EV.xs
EV.pm
EV/EVAPI.h
EV/MakeMaker.pm
t/00_load.t
t/01_timer.t
t/02_once.t
t/03_keepalive.t
t/04_stat.t
t/05_priority.t
t/06_loop_once.t
t/07_loop_timer.t
t/08_async.t
t/09_brandon.t
#t/10_nheap.t # too timing-sensitive
t/11_signal.t
libev/LICENSE
$backend = EV::backend
$backend = $loop->backend
Returns an integer describing the backend used by libev
(EV::BACKEND_SELECT or EV::BACKEND_EPOLL).
$active = EV::run [$flags]
$active = $loop->run ([$flags])
Begin checking for events and calling callbacks. It returns when a
callback calls EV::break or the flags are nonzero (in which case the
return value is true) or when there are no active watchers which
reference the loop (keepalive is true), in which case the return
value will be false. The return value can generally be interpreted
as "if true, there is more work left to do".
The $flags argument can be one of the following:
0 as above
EV::RUN_ONCE block at most once (wait, but do not loop)
EV::RUN_NOWAIT do not block at all (fetch/handle events but do not wait)
EV::break [$how]
$w->feed_event ($revents)
Feed some events on this watcher into EV. EV will react to this call
as if the watcher had received the given $revents mask.
$revents = $w->clear_pending
If the watcher is pending, this function clears its pending status
and returns its $revents bitset (as if its callback was invoked). If
the watcher isn't pending it does nothing and returns 0.
$previous_state = $w->keepalive ($bool)
Normally, "EV::run" will return when there are no active watchers
(which is a "deadlock" because no progress can be made anymore).
This is convenient because it allows you to start your watchers (and
your jobs), call "EV::run" once and when it returns you know that
all your jobs are finished (or they forgot to register some watchers
for their task :).
Sometimes, however, this gets in your way, for example when the
module that calls "EV::run" (usually the main program) is not the
same module as a long-living watcher (for example a DNS client
module written by somebody else even). Then you might want any
outstanding requests to be handled, but you would not want to keep
"EV::run" from returning just because you happen to have this
long-running UDP port watcher.
In this case you can clear the keepalive status, which means that
even though your watcher is active, it won't keep "EV::run" from
returning.
The initial value for keepalive is true (enabled), and you can
change it any time.
Example: Register an I/O watcher for some UDP socket but do not keep
the event loop from running just because of that watcher.
my $udp_socket = ...
my $udp_watcher = EV::io $udp_socket, EV::READ, sub { ... };
$udp_watcher->keepalive (0);
$loop = $w->loop
Return the loop that this watcher is attached to.
WATCHER TYPES
Each of the following subsections describes a single watcher type.
I/O WATCHERS - is this file descriptor readable or writable?
$w = EV::io $fileno_or_fh, $eventmask, $callback
$w = EV::io_ns $fileno_or_fh, $eventmask, $callback
$w = $loop->io ($fileno_or_fh, $eventmask, $callback)
$w = $loop->io_ns ($fileno_or_fh, $eventmask, $callback)
As long as the returned watcher object is alive, call the $callback
when at least one of events specified in $eventmask occurs.
The $eventmask can be one or more of these constants ORed together:
EV::READ wait until read() wouldn't block anymore
EV::WRITE wait until write() wouldn't block anymore
The "io_ns" variant doesn't start (activate) the newly created
watcher.
/* so must not be executed on windows */
dup2 (fds [1], evpipe [1]);
close (fds [1]);
}
fd_intern (evpipe [1]);
ev_io_set (&pipe_w, evpipe [0] < 0 ? evpipe [1] : evpipe [0], EV_READ);
ev_io_start (EV_A_ &pipe_w);
ev_unref (EV_A); /* watcher should not keep loop alive */
}
}
inline_speed void
evpipe_write (EV_P_ EV_ATOMIC_T *flag)
{
ECB_MEMORY_FENCE; /* push out the write before this function was called, acquire flag */
if (ecb_expect_true (*flag))
return;
{
timerfd = timerfd_create (CLOCK_REALTIME, TFD_NONBLOCK | TFD_CLOEXEC);
if (timerfd >= 0)
{
fd_intern (timerfd); /* just to be sure */
ev_io_init (&timerfd_w, timerfdcb, timerfd, EV_READ);
ev_set_priority (&timerfd_w, EV_MINPRI);
ev_io_start (EV_A_ &timerfd_w);
ev_unref (EV_A); /* watcher should not keep loop alive */
/* (re-) arm timer */
timerfdcb (EV_A_ 0, 0);
}
}
}
#endif
/*****************************************************************************/
#endif
loop_init (EV_A_ flags);
if (ev_backend (EV_A))
{
#if EV_CHILD_ENABLE
ev_signal_init (&childev, childcb, SIGCHLD);
ev_set_priority (&childev, EV_MAXPRI);
ev_signal_start (EV_A_ &childev);
ev_unref (EV_A); /* child watcher should not keep loop alive */
#endif
}
else
ev_default_loop_ptr = 0;
}
return ev_default_loop_ptr;
}
void
if (sigfd >= 0)
{
fd_intern (sigfd); /* doing it twice will not hurt */
sigemptyset (&sigfd_set);
ev_io_init (&sigfd_w, sigfdcb, sigfd, EV_READ);
ev_set_priority (&sigfd_w, EV_MAXPRI);
ev_io_start (EV_A_ &sigfd_w);
ev_unref (EV_A); /* signalfd watcher should not keep loop alive */
}
}
if (sigfd >= 0)
{
/* TODO: check .head */
sigaddset (&sigfd_set, w->signum);
sigprocmask (SIG_BLOCK, &sigfd_set, 0);
signalfd (sigfd, &sigfd_set, 0);
libev/ev_iouring.c view on Meta::CPAN
if (iouring_internal_init (EV_A) < 0)
{
iouring_internal_destroy (EV_A);
return 0;
}
ev_io_init (&iouring_tfd_w, iouring_tfd_cb, iouring_tfd, EV_READ);
ev_set_priority (&iouring_tfd_w, EV_MINPRI);
ev_io_start (EV_A_ &iouring_tfd_w);
ev_unref (EV_A); /* watcher should not keep loop alive */
backend_modify = iouring_modify;
backend_poll = iouring_poll;
return EVBACKEND_IOURING;
}
inline_size
void
iouring_destroy (EV_P)
libev/ev_linuxaio.c view on Meta::CPAN
if (linuxaio_io_setup (EV_A) < 0)
{
epoll_destroy (EV_A);
return 0;
}
ev_io_init (&linuxaio_epoll_w, linuxaio_epoll_cb, backend_fd, EV_READ);
ev_set_priority (&linuxaio_epoll_w, EV_MAXPRI);
ev_io_start (EV_A_ &linuxaio_epoll_w);
ev_unref (EV_A); /* watcher should not keep loop alive */
backend_modify = linuxaio_modify;
backend_poll = linuxaio_poll;
linuxaio_iocbpmax = 0;
linuxaio_iocbps = 0;
linuxaio_submits = 0;
linuxaio_submitmax = 0;
linuxaio_submitcnt = 0;
t/03_keepalive.t view on Meta::CPAN
BEGIN { $| = 1; print "1..8\n"; }
no warnings;
use strict;
use EV;
my $timer = EV::timer_ns 1, 0.3, sub { print "ok 7\n"; $_[0]->stop };
$timer->keepalive (1);
print "ok 1\n";
EV::run;
print "ok 2\n";
$timer->start;
$timer->keepalive (0);
$timer->again;
$timer->stop;
$timer->start;
my $timer2 = EV::timer -1, 0, sub { print "ok 4\n" };
$timer2->keepalive (0);
print "ok 3\n";
EV::run;
print "ok 5\n";
$timer->keepalive (1);
print "ok 6\n";
EV::run;
print "ok 8\n";
( run in 0.790 second using v1.01-cache-2.11-cpan-39bf76dae61 )