Skip to content

Instantly share code, notes, and snippets.

@m4rw3r
Created January 27, 2012 10:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m4rw3r/1688204 to your computer and use it in GitHub Desktop.
Save m4rw3r/1688204 to your computer and use it in GitHub Desktop.
Current feature-set of php-libev vs libev

Differences in the PHP-libev vs libev API

This list is subject to change as the PHP-libev API changes. The goal of this list is to keep track of differences and see if stuff needs to change, it also serves as a todo list for stuff which currently is not implemented in PHP-libev.

libev PHP-libev
ev_time() not implemented
ev_sleep(interval) not implemented
ev_version_major() supported in minfo
ev_version_minor() supported in minfo
ev_supported_backends() not implemented
ev_recommended_backends() not implemented
ev_set_allocator() used, wrapping erealloc() and efree()
ev_set_syserr_cb() not used
ev_feed_signal() not used
ev_loop EventLoop
ev_default_loop(flags) EventLoop::getDefaultLoop()
loop = ev_loop_new(flags) $loop = new EventLoop()

ev_loop_destroy(loop)

unset($loop) destroyed when refcount == 0

ev_loop_destroy(EV_DEFAULT) not implemented, only done on script exit
ev_loop_fork(loop) $loop->notifyFork()
ev_is_default_loop(loop) $loop->isDefaultLoop()
ev_iteration(loop) $loop->getIteration()
ev_depth(loop) $loop->getDepth()
ev_backend(loop) $loop->getBackend()
ev_now(loop) $loop->now()
ev_now_update(loop) $loop->updateNow()
ev_suspend(loop) $loop->suspend()
ev_resume(loop) $loop->resume()
ev_run(loop, flags) $loop->run(flags)
ev_break(loop, how) $loop->breakLoop(how)
ev_ref(loop) $loop->ref()
ev_unref(loop) $loop->unref()
ev_set_io_collect_interval(loop, interval) $loop->setIOCollectInterval(interval)
ev_set_timeout_collect_interval(lo, in) $loop->setTimeoutCollectInterval(in)
ev_invoke_pending(loop) not implemented
ev_pending_count(loop) $loop->getPendingCount()
ev_set_invoke_pending_cb(loop, cb) not implemented
ev_set_loop_release_cb(loop, cb) not implemented
ev_set_userdata(loop, data) not used, users set properties on Event object

ev_set_verify(loop) Events

sometimes used if debug

ev_init no analogue, Event is abstract
ev_TYPE_set no analogue, TYPEEvent is inited by ctor
ev_TYPE_init(ev, cb, args) $ev = new TYPEEvent(cb, args)

ev_TYPE_start(loop, ev)

$loop->add($ev) increases refcount of $ev, will be decreased when EventLoop is freed, $loop->remove($ev) or $ev->stop() is called or when event is no longer active (eg. one-shot timer)

ev_TYPE_stop(loop, ev)

$loop->remove($ev), $ev->stop() both decreases refcount of $ev

ev_is_active(ev) $ev->isActive()
ev_is_pending(ev) $ev->isPending()
ev_cb(ev) not implemented
ev_cb_set(ev, cb) $ev->setCallback($cb)
ev_set_priority(ev, prio) not implemented
ev_priority(ev) not implemented
ev_invoke(ev, revents) $ev->invoke([revents = 0])
ev_clear_pending(loop, ev) $ev->clearPending()
ev_feed_event(loop, ev, revents) $loop->feedEvent($ev[, revents = 0])
ev_io IOEvent
ev_io_init(ev, cb, fd, events) $ev = new IOEvent(cb, stream, events)
ev_timer TimerEvent
ev_timer_init(ev, cb, after, repeat) $ev = new TimerEvent(cb, after[, repeat = 0])

ev_timer_again(loop, ev)

$ev->again() no optional loop param, so can't start if needed

ev_timer_remaining(loop, ev) $ev->getRemaining()
ev_timer->repeat = interval $ev->setRepeat(interval)
ev_timer->repeat $ev->getRepeat()
ev_periodic PeriodicEvent

ev_periodic_init(ev, cb, offs, int, recb)

$ev = new PeriodicEvent(cb, offs[, int = 0]) no reschedule callback

ev_periodic_again(loop, ev)

$ev->again() no optional loop param, so can't start if needed

ev_periodic_at(ev) $ev->getTime()
ev_periodic->offset $ev->getOffset()
ev_periodic->offset = offs not implemented
ev_periodic->interval $ev->getInterval()
ev_periodic->interval = inter $ev->setInterval(inter)
reschedule_cb not implemented
ev_signal SignalEvent
ev_signal_init(ev, cb, signum) $ev = new SignalEvent(cb, signum)
ev->signum not implemented
ev->signum = sig not implemented
ev_child ChildEvent
ev_child_init(ev, cb, pid, trace) $ev = new ChildEvent(cb, pid[, trace = false])
ev->pid $ev->getPid()
ev->rpid $ev->getRPid()
ev->rstatus $ev->getRStatus()
ev_stat StatEvent
ev_stat_init(ev, cb, path, interval) $ev = new StatEvent(cb, path[, interval])
ev_stat_stat(loop, ev) not implemented
ev->attr $ev->getAttr()
ev->prev $ev->getPrev()
ev->interval $ev->getInterval()
ev->path $ev->getPath()
ev_idle IdleEvent
ev_idle_init(ev, cb) $ev = new IdleEvent(cb)
ev_prepare not implemented
ev_prepare_init(ev, cb) not implemented
ev_check not implemented
ev_check_init(ev, cb) not implemented
ev_embed not implemented
ev_embed_init(ev, cb, loop) not implemented
ev_embed_sweep(loop, ev) not implemented
ev->other not implemented
ev_fork not implemented
ev_fork_init(ev, cb) not implemented
ev_cleanup not implemented
ev_cleanup_init(ev, cb) not implemented
ev_async AsyncEvent
ev_async_init(ev, cb) $ev = new AsyncEvent(cb)
ev_async_pending(ev) not implemented
ev_async_send(loop, ev) $ev->send()
Other functions Other
ev_once(loop, fd, events, timeout, cb) not implemented
ev_feed_fd_event(loop, fd, revents) not implemented
ev_feed_signal_event(loop, signum) not implemented
Callback syntax Callback syntax
void cb(loop, ev, revents) void $func(Event $ev, int $revents)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment