Boost Users :
From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2008-05-19 14:11:26
-----BEGIN PGP SIGNED MESSAGE-----
On Monday 19 May 2008 11:54 am, Igor R. wrote:
> I'd like to use thread_safe_signals, and I'm wondering if there're any
> examples that highlight use-cases where the thread-safety is utilized?
Hmm, unfortunately there isn't much like that.
> instance, is it safe to connect() from a thread, while the signal is
> "signaling" in another thread?
> Is it safe to signal from a thread while
> another thread might destroy the signal?
In gernal, there's no way I could prevent someone from trying to use a
reference or pointer to a signal object that has already been destroyed.
However, if you construct a slot "slotB" with a matching signature directly
from a signal "sigA" (not wrapped in a bind) and track sigA, then it is
actually safe to run the slot. If sigA has already been destroyed when slotB
is run, then slotB will expire and disconnect. If sigA is destroyed while
slotB in mid-run, the guts of sigA will be kept alive by slotB until it
> Another question: what would be the most simple way to do asynchronous
> signaling? Probably, there already exists something in boost (even not
> officially released) that provides such a functionality? I mean something
> like this: at the stage of connecting to a signal I'd like to supply an
> asynchronous queue along with slot handler, and at the stage of signaling
> the signal - instead of direct execution of a functor - must just post it
> to the associated queue (slots' return values are not of interest to me).
I don't think such things are within the scope of a signals library. You can
however implement your slot to queue whatever you like wherever you like.
For example, I've written slots that post events to event queues
(QApplication::postEvent from the Qt library) or invoke active objects
(poet::active_function from libpoet).
Boost Thread, Asio, or Interprocess might be helpful to you in implementing
your asynchronous queue.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
-----END PGP SIGNATURE-----
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