|
Boost Users : |
From: Nat Goodspeed (ngoodspeed_at_[hidden])
Date: 2006-10-25 08:20:37
> -----Original Message-----
> From: boost-users-bounces_at_[hidden] [mailto:boost-users-
> bounces_at_[hidden]] On Behalf Of Matt Davies
> Sent: Tuesday, October 24, 2006 4:33 PM
> To: boost-users_at_[hidden]
> Subject: [Boost-users] Deferred Function calls
>
> I am implementing a signal & slots implementation with a twist.
Normally
> when a signal is fired the connected slots are called immediately. I
will
> need to defer the actual calls to be invoked later. Basically I need
to
> store the function reference (via pointer or functor) and the
accompanying
> parameter values to a 'composite' object. This composite object will
be
> stored on a buffer. Later another processor will pick this object of
the
> buffer and then invoke the actual function call.
[Nat] Let me try to paraphrase the question to see if I understand.
You aren't directly using Boost.Signals because when you call a signal
it immediately passes control to each of its slots.
Your slots have non-empty parameter signatures. The code that triggers
the deferred call has matching argument values. If an immediate call
were acceptable, you'd simply use a boost::signal and call it with those
argument values.
So... as Delfin Rojas suggested, you could use boost::bind to bind your
boost::signal object with the argument values you later want passed to
each connected slot. (I haven't tried this myself.) In the absence of
bind placeholders (e.g. _1), bind will produce a nullary functor that
you can store in a boost::function<void (void)>. When you later call
that functor with no arguments, it should call each connected slot with
the bound arguments.
If this doesn't answer your question, please explain what we're missing.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net