On 7/23/21 12:37 PM, Thiago Macieira via Std-Proposals wrote:
On Thursday, 22 July 2021 23:25:14 PDT Tony V E via Std-Proposals wrote:
Boost Signals2 is about as thread safe as possible (and I helped with the
design of it)‎, but a slot can still deadlock in a weird edge case.

As long as you don't grab locks in your slots you are fine, but that is
easier said than done - people call functions that call functions that...
grab locks that you aren't aware of.
We have the same problem in Qt. As a rule of thumb, never call back to user 
code with acquired locks and signal emission counts as calling back to user 
code.

Moreover, we often have also to deal with the current object (this) having 
been deleted in that very callback. So the rule of thumb is to emit signals at 
the very end of your function, after you've dropped the locks and are ready to 
return any way.


You could mimic and abstract to a certain point the POSIX signals as well (which are pretty messy in a multithreaded environment when you apply some masks in some specific thread).



    
--

Phil Bouchard
Founder & CTO
C.: (819) 328-4743

Fornux Logo