libev callback mechanism
Marc Lehmann
schmorp at schmorp.de
Sat Dec 10 16:47:51 CET 2011
On Fri, Dec 09, 2011 at 07:54:25AM -0600, vanv0059 at umn.edu wrote:
> far with respect using libev to handle the async functions of Redis
> (a key-value+ store). Is there documentation about how callbacks
> "work"?
Well, a callback is simply a function that is being called, no magic
involved. To my knowledge, this is what callback means everywhere else as
well.
> That is the mechanism used to transfer control to the
> callback function and back to the process' thread of control.a
Libev is an event library, it doesn't implement/use/expose threads - a
callback doesn't transfer control to another thread, only to the callback,
via a simple function call.
> I just answered this myself as libev requires explicit loop calls --
> either the process is controlled by an ev_loop or it is controlled
> explicitly by the process (i.e. no current ev_loops running).
ev_loop does not take control of the process, only of the thread that it
is called in, for as long as you tell it.
> My main reason for this question is if I produce an object in one
> process/thread and consume it in that same process/thread via a
> callback do I need to lock that object?
depends on how else you use your object. in the absence of any other users,
you do not need to lock your object, unless you want to keep the lock for
longer than just the callback.
--
The choice of a Deliantra, the free code+content MORPG
-----==- _GNU_ http://www.deliantra.net
----==-- _ generation
---==---(_)__ __ ____ __ Marc Lehmann
--==---/ / _ \/ // /\ \/ / schmorp at schmorp.de
-=====/_/_//_/\_,_/ /_/\_\
More information about the libev
mailing list