digitalmars.D.learn - Signals using shared slots
- Dechcaudron (24/24) Jun 16 2016 Hey there,
Hey there, I'm currently starting to use signals. They are great (thanks Walter!) but there is an important limitation since the only slots it can take are non-shared, which forces them to operate within a single thread. I understand the `Not safe for multiple threads operating on the same signals or slots.` notice in https://dlang.org/phobos/std_signals.html, but this is not about operating them in different threads. It is about calling shared methods, which should probably be supported, since I might want to issue callbacks to shared instances (and indeed I do). Still, regarding that notice, I understand we are to externally synchronize calls to the signal's methods if we intent to use signals in __gshared mode, right? Currently there is a thing going on in my program I don't quite understand (though it works): I pass a delegate of a TL object as a slot to a manually synchronized signal, only to later call emit on that signal from a different thread. The result: it indeed ends up calling the right instance but apparently breaking TLS. Checking the direction of a TL int variable from methods called from different threads issue the very same pointer value, even though this int variable, as well as the whole object instance, should be confined to the original thread. Am I getting something wrong about the whole threading thing?
Jun 16 2016