본문 바로가기

misc./libev & libeio

libev - some functions controlling the event loop

Functions Controlling the Event Loop


An event loop is described by a struct ev_loop*.

The library knows two types of such loop, the default loop, and dynamically created loops.


struct ev_loop *ev_default_loop(unsigned int flags)

  • This will initialize the default event loop if it hasn't been initialized yet and return it.
  • If the default loop could not be initialized, return false.
  • If it already was initialized it simply return in.
  • NOTE: this function is not thread-safe.
  • The default loop is the only loop that can handle ev_signal and ev_child watchers.


struct ev_loop *ev_loop_new(unsigned int flags)

  • Creates a new event loop that is always distinct from the default loop.
  • It cannot handle signal and child watchers.
  • NOTE: this function is thread-safe.
  • The recommended way to use libev with threads is to create one loop per thread.


ev_default_destroy()

  • destroys the default loop.
  • None of the active event watchers will be stopped.


ev_loop_destroy(loop)

  • Destroys an event loop created by an earlier call to ev_loop_new.


ev_run(loop, int flags)

  • The event handler.
  • this function usually is called after you initialized all your watchers and you want to start handling events.


ev_break(loop, how)

  • Can be used to make a call to ev_loop return early(but only it has processed all outstanding events).

ev_ref(loop)
ev_unref(loop)
  • ref/unref can be used to add or remove a reference count on the event loop
  • Every watcher keeps one reference.
  • As long as the reference count is non zero, ev_loop will not return on its own.


reference: http://doc.dvgu.ru/devel/ev.html#functions_controlling_the_event_loop


'misc. > libev & libeio' 카테고리의 다른 글

libeio - example: cp  (0) 2012.07.09
libev - example: stdin  (0) 2012.07.09
libev - example: timer  (0) 2012.07.09
ANATOMY OF A WATCHER  (0) 2012.07.09
libev, libeio  (0) 2012.07.08