(PECL ev >= 0.2.0)
Ev is a static class providing access to the default loop and to some common operations.
Flags passed to create a loop:
Ev::FLAG_AUTO
Ev::FLAG_NOENV
libev
won't look at the environment variable
LIBEV_FLAGS.
Otherwise(by default),
LIBEV_FLAGS
will override the flags completely if it is found. Useful for
performance tests and searching for bugs.
Ev::FLAG_FORKCHECK
getpid()
on every iteration of the loop, and thus this might slow down the
event loop with lots of loop iterations, but usually is not
noticeable. This flag setting cannot be overridden or specified in the
LIBEV_FLAGS
environment variable.
Ev::FLAG_NOINOTIFY
libev
won't attempt to use the
inotify
API for its
» ev_stat
watchers. The flag can be useful to conserve inotify file descriptors,
as otherwise each loop using
ev_stat
watchers consumes one
inotify
handle.
Ev::FLAG_SIGNALFD
libev
will attempt to use the
signalfd
API for its
» ev_signal
(and
» ev_child)
watchers. This API delivers signals synchronously, which makes it
both faster and might make it possible to get the queued signal data.
It can also simplify signal handling with threads, as long as signals
are properly blocked in threads.
Signalfd
will not be used by default.
Ev::FLAG_NOSIGMASK
libev
will avoid to modify the signal mask. Specifically, this means having
to make sure signals are unblocked before receiving them.
This behaviour is useful for custom signal handling, or handling
signals only in specific threads.
Flags passed to Ev::run(), or EvLoop::run()
Ev::RUN_NOWAIT
Ev::RUN_ONCE
Flags passed to Ev::stop(), or EvLoop::stop()
Ev::BREAK_CANCEL
Ev::BREAK_ONE
Ev::BREAK_ALL
Watcher priorities:
Ev::MINPRI
Ev::MAXPRI
Bit masks of (received) events:
Ev::READ
Ev::WRITE
Ev::TIMER
Ev::PERIODIC
Ev::SIGNAL
Ev::CHILD
pid
specified in
EvChild::__construct()
has received a status change.
Ev::STAT
Ev::IDLE
Ev::PREPARE
Ev::CHECK
Ev::EMBED
Ev::CUSTOM
libev
itself, but can be freely used by
libev
users to signal watchers (e.g. via
EvWatcher::feed()
).
Ev::ERROR
libev
ran out of memory, a file descriptor was found to be closed or any
other problem.
Libev
considers these application bugs. See also
» ANATOMY
OF A WATCHER
Backend flags:
Ev::BACKEND_SELECT
select(2) backend
Ev::BACKEND_POLL
poll(2) backend
Ev::BACKEND_EPOLL
epoll(7)
backend for both pre- and post-2.6.9 kernels
Ev::BACKEND_KQUEUE
kqueue
backend used on most BSD systems.
EvEmbed
watcher could be used to embed one loop(with kqueue backend) into
another. For instance, one can try to create an event loop with
kqueue
backend and use it for sockets only.
Ev::BACKEND_DEVPOLL
Ev::BACKEND_PORT
Ev::BACKEND_ALL
Ev::BACKEND_ALL
& ~
Ev::BACKEND_KQUEUE)
Use
Ev::recommendedBackends(),
or don't specify any backends at all.
Ev::BACKEND_MASK
flags
value to mask out any backends(e.g. when modifying the
LIBEV_FLAGS
environment variable).
注意: For the default loop during module initialization phase
Evregisters » ev_loop_fork call by means ofpthread_atfork(if available).
注意: There are methods providing access to the default event loop in Ev class(e.g. Ev::iteration(), Ev::depth() etc.) For custom loops (created with EvLoop::__construct()) these values may be accessed via corresponding properties and methods of the EvLoop class. The instance of the default event loop itself can be fetched by means of EvLoop::defaultLoop() method.