Threaded Example clarification
Marc Lehmann
schmorp at schmorp.de
Mon Nov 17 05:28:11 CET 2014
On Thu, Nov 13, 2014 at 05:34:16PM -0500, Anthony Clark <clark.anthony.g at gmail.com> wrote:
> I tried going through the perl module
Since the documentation is making a fictituous example, which perl module
are you refering to? The only perl modules mentioned are EV::Loop::Async
and Async::Interrupt - which of these is _the_ module?
> but I never saw what `sig_func` or `sig_arg` were.
Hmm, the only occurance of these are indeed in EV::Loop::Async - sig_func and
sig_arg in EV::Loop::Async are provided by Async::Interrupt.
> Maybe if I knew those, I'd get a hint.
Still, the example in the manpage does not rely on those perl modules in any
way, so all you should need is in those examples - where sig_func is
"wake_up_other_thread_in_some_magic_or_not_so_magic_way", i.e. it has to be
provided by you.
e.g. if your "other_thread" is using libev, you can use ev_async. another
popular mechanisms is to use a pipe. and for perl, you might want to use
Async::Interrupt (or a pipe).
> Since the loop (in the Thread Locking example) is processes solely in
> a separate (from main) thread,
The example states that the main thread is what processes callbacks,
so the loop is clearly pörocessed in the main threead (and the other
thread).
> what could/would the main thread need to know about?
It would need to know about the events it has to process.
> It doesn't appear that `real_invoke_pending` is never actually invoked in
> the Thread Locking example.
It is, from whatever mechanism used to interrupt the main thread (e.g.
from whatever magic wake_up_other_thread_in_some_magic_or_not_so_magic_way
does).
> In the perl module, it's handled by the module system (c_func) and I
> can't really figure it out where in the flow it's actually invoked.
It's invoked by Async::Interrupt, which is the interruption mechanism that
EV::Loop::Async uses.
> So to narrow it down. I understand the acquire/release callbacks, I
> understand locking `ev_run`. I guess I just don't understand the flow of
> the invoke_pending callback. Any help is appreciated! Also, sorry for the
> newbie questions.
No problem with newbie questions, but what actually are your questions? You
never stated what problem you are trying to solve, and what questions are
open with respect to that problem, so its abit hard to help you.
What you should do is state what you are trying to achieve, and where you
are blocked.
Greetings,
--
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