Boost.Signals2 - if slot (functor of lambda) destructs the signal, calling the slot itself -> safe for functor?
Hi there,
If I connect a signal to a slot (functor or lambda), and the signal is
then run, it calls the slot.
What if the slot now has code that causes the signal to destruct?
Will this "self-destruct" the slot (functor or lambda), by calling
it's destructor BEFORE the slot-call has finished executing??? This
would be a disaster!
But it seems like is is safe.
It seems:
Even if the signal is destructed (from it's own slot-call), the slot
destructor does not yet get called, until the slot-call has finished.
Which would be safe.
(Code example below)
But is this really the case? Is this always safe? (If so: how does
this roughly work?)
Thanks.
/////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include
Just to show an example (not using Signals2), where we can
self-destruct a Functor:
This is unsafe (disaster) code.
///////////////////////////////////////////////////////////////////
#include <iostream>
#include <map>
#include <functional>
#include <algorithm>
using namespace std;
using FuncSig = void();
using Func = function<FuncSig>;
class Functor {
public:
Functor(map
Oh and an absolute basics question...
Does the connect function copy functors?
I believe it does, so the code below would be safe.
(Is that correct????)
Thanks
boost::signals2::signal
participants (1)
-
nice sw123