« Return to Thread: [signals/threadsafe version] Atomic disconnects

[signals/threadsafe version] Atomic disconnects

by Johan Torp :: Rate this Message:

Reply to Author | View in Thread

I'm wondering if the new thread safe implementation of signals guarantees atomic disconnects.

line1: signal<void(), multi_threaded> sig;
line2: thread t(sig); // Start a new thread which will emit "sig"
line3: sig.connect(&some_func);
line4: sig.disconnect(&some_func);
line5: ...

Am I guaranteed that some_func isn't called at line 5 or afterwards?


If disconnect is blocking, how do you prevent the following dead-lock during signal emission?
- Emitting thread tries to acquire a mutex X via a slot
- Disconnect calling thread is holding X and gets blocked on disconnect


Best Regards, Johan Torp


 « Return to Thread: [signals/threadsafe version] Atomic disconnects