digitalmars.D.announce - sslot 0.3 release
- Lutger (20/20) Mar 28 2007 I have updated sslot, a signal-slots library.
- Dejan Lekic (1/1) Mar 28 2007 Lutger, is sslot thread-safe?
- Lutger (2/3) Mar 28 2007 No, not yet. I'm still figuring out what I have to do to make it so.
- Dejan Lekic (3/3) Mar 28 2007 Lutger, my suggestion is to do what QT does - http://doc.trolltech.com/4...
- Witold Baryluk (6/7) Mar 28 2007 http://www.digitalmars.com/d/phobos/std_signals.html
- Witold Baryluk (3/3) Mar 28 2007 Sorry, i misunderstood your post. So ignore mine.
- Lutger (10/15) Mar 28 2007 Thank you for the link. It is still not clear to me what is necessary,
- Lutger (5/26) Mar 29 2007 I found the answers to my own questions, but upon reflection there seems...
- Sean Kelly (64/91) Mar 29 2007 There are a few different approaches available, depending on the
- Lutger (7/15) Mar 29 2007 Thank you very much! I realized a similar scheme is also necessary for
- Dejan Lekic (1/1) Mar 30 2007 Mr. Kelly, this is more/less what I would like to have in std.signals .....
- Sean Kelly (3/5) Mar 30 2007 I think you'll have to ask Mr. Bright :-)
- Bill Baxter (3/28) Mar 28 2007 Sounds nice. Just curious -- what is it you require from dmd 1.10?
- Lutger (7/11) Mar 28 2007 dmd 1.10 provides std.gc.capacity, which can tell you if a block of
- Frits van Bommel (4/14) Mar 28 2007 You realize that just because a block of memory is GC-allocated doesn't
- Lutger (5/20) Mar 28 2007 Yes of course. This block comes from the .ptr property of a delegate
I have updated sslot, a signal-slots library. links: http://lutger.ifastnet.com/ http://lutger.ifastnet.com/sslot/overview.html Some of it's features are: - return values - can connect functions, delegates, functors, etc. - signals are iterable - managed connections Here is the changelog for this version. * blocking slots is removed for simplicity * Object references are not needed anymore to connect managed slots * Slot implementation is now a 'policy' template * implemented combiners with mapReduce, see MapSignal * performance improvements * fixed defaultHandler bug * removed dependency on meta.nameof * fixed support for functor types * requires dmd 1.10 * backTrace with version=sslotBackTrace
Mar 28 2007
Dejan Lekic wrote:Lutger, is sslot thread-safe?No, not yet. I'm still figuring out what I have to do to make it so.
Mar 28 2007
Lutger, my suggestion is to do what QT does - http://doc.trolltech.com/4.2/threads.html#signals-and-slots-across-threads Kind regards PS. I would like to see this in Phobos' signal/slot implementation.
Mar 28 2007
On Wed, 28 Mar 2007 14:10:23 -0400 Dejan Lekic <dejan.lekic gmail.com> wrote:PS. I would like to see this in Phobos' signal/slot implementation.http://www.digitalmars.com/d/phobos/std_signals.html :) -- Witold Baryluk
Mar 28 2007
Sorry, i misunderstood your post. So ignore mine. -- Witold Baryluk
Mar 28 2007
Dejan Lekic wrote:Lutger, my suggestion is to do what QT does - http://doc.trolltech.com/4.2/threads.html#signals-and-slots-across-threads Kind regards PS. I would like to see this in Phobos' signal/slot implementation.Thank you for the link. It is still not clear to me what is necessary, the QT s/s mechanism is tightly integrated to the whole framework so not seems to be applicable. What it comes down to looks like a lot of mutexes to me though. I am not so familiar with multi-threaded programming, perhaps you can help me with these questions: Would it be preferable to have a thread safety as an option, and if so in what way? Versioning or seperate classes? Do reads from (non-volatile) data need to be synchronized?
Mar 28 2007
Lutger wrote:Dejan Lekic wrote:I found the answers to my own questions, but upon reflection there seems to be a lot of potential for deadlocks. It will probably take a while for me to figure out the details, I don't want to infest sslot with subtle bugs.Lutger, my suggestion is to do what QT does - http://doc.trolltech.com/4.2/threads.html#signals-and-slots-across-threads Kind regards PS. I would like to see this in Phobos' signal/slot implementation.Thank you for the link. It is still not clear to me what is necessary, the QT s/s mechanism is tightly integrated to the whole framework so not seems to be applicable. What it comes down to looks like a lot of mutexes to me though. I am not so familiar with multi-threaded programming, perhaps you can help me with these questions: Would it be preferable to have a thread safety as an option, and if so in what way? Versioning or seperate classes? Do reads from (non-volatile) data need to be synchronized?
Mar 29 2007
Lutger wrote:Lutger wrote:There are a few different approaches available, depending on the guarantees want to provide. I think Andrei actually wrote an article on this, but I'll be darned if I can find it right now. One approach would be something like this: void attach( Slot s ) { synchronized { if( !signaling ) { slots ~= s; return; } queue ~= AddRemove( s, true ); } } void detach( Slot s ) { synchronized { if( !signaling ) { slots.remove( s ); return; } queue ~= AddRemove( s, false ); } } void signal() { synchronized { ++signaling; } foreach( s; slots ) { s(); } synchronized { if( signaling == 1 ) { foreach( m; queue ) { if( m.isAdd ) slots ~= s; else slots.remove( s ); } } --signaling; } } struct AddRemove { Slot slot; bool isAdd; } The tradeoff here is twofold: first, the signal mechanism must acquire two locks to send a signal, and second, the processing of add/remove requests is asynchronous when a signal is being sent. Still, it only uses one lock and behavior is fairly predictable. SeanDejan Lekic wrote:I found the answers to my own questions, but upon reflection there seems to be a lot of potential for deadlocks. It will probably take a while for me to figure out the details, I don't want to infest sslot with subtle bugs.Lutger, my suggestion is to do what QT does - http://doc.trolltech.com/4.2/threads.html#signals-and-slots-across-threads Kind regards PS. I would like to see this in Phobos' signal/slot implementation.Thank you for the link. It is still not clear to me what is necessary, the QT s/s mechanism is tightly integrated to the whole framework so not seems to be applicable. What it comes down to looks like a lot of mutexes to me though. I am not so familiar with multi-threaded programming, perhaps you can help me with these questions: Would it be preferable to have a thread safety as an option, and if so in what way? Versioning or seperate classes? Do reads from (non-volatile) data need to be synchronized?
Mar 29 2007
Sean Kelly wrote: <snipThe tradeoff here is twofold: first, the signal mechanism must acquire two locks to send a signal, and second, the processing of add/remove requests is asynchronous when a signal is being sent. Still, it only uses one lock and behavior is fairly predictable. SeanThank you very much! I realized a similar scheme is also necessary for single-threaded code, since removal *may* happen during signalling if the GC is run. My apologies for this bug. I actually had this solved in some previous implementation but it slipped back in again.
Mar 29 2007
Mr. Kelly, this is more/less what I would like to have in std.signals ... Is there any chance Mr. Bright will do this? :)
Mar 30 2007
Dejan Lekic wrote:Mr. Kelly, this is more/less what I would like to have in std.signals ... Is there any chance Mr. Bright will do this? :)I think you'll have to ask Mr. Bright :-) Sean
Mar 30 2007
Lutger wrote:I have updated sslot, a signal-slots library. links: http://lutger.ifastnet.com/ http://lutger.ifastnet.com/sslot/overview.html Some of it's features are: - return values - can connect functions, delegates, functors, etc. - signals are iterable - managed connections Here is the changelog for this version. * blocking slots is removed for simplicity * Object references are not needed anymore to connect managed slots * Slot implementation is now a 'policy' template * implemented combiners with mapReduce, see MapSignal * performance improvements * fixed defaultHandler bug * removed dependency on meta.nameof * fixed support for functor types * requires dmd 1.10 * backTrace with version=sslotBackTraceSounds nice. Just curious -- what is it you require from dmd 1.10? --bb
Mar 28 2007
Bill Baxter wrote:Sounds nice. Just curious -- what is it you require from dmd 1.10? --bbdmd 1.10 provides std.gc.capacity, which can tell you if a block of memory is allocated by the gc. I use this to check if a delegates comes from an object (with the .ptr property), in which case the signals hooks a delegate with notifyRegister on the object which is called on destruction for auto disconnection. I should have documented this btw.
Mar 28 2007
Lutger wrote:Bill Baxter wrote:You realize that just because a block of memory is GC-allocated doesn't mean it's an Object? It could just as well be a struct, int, dynamic array data or whatever.Sounds nice. Just curious -- what is it you require from dmd 1.10?dmd 1.10 provides std.gc.capacity, which can tell you if a block of memory is allocated by the gc. I use this to check if a delegates comes from an object (with the .ptr property), in which case the signals hooks a delegate with notifyRegister on the object which is called on destruction for auto disconnection. I should have documented this btw.
Mar 28 2007
Frits van Bommel wrote:Lutger wrote:Yes of course. This block comes from the .ptr property of a delegate which is already type checked, so there are just a few types left which are unsafe to connect. That's why I said I should have documented it, kinda stupid to leave this important information out...Bill Baxter wrote:You realize that just because a block of memory is GC-allocated doesn't mean it's an Object? It could just as well be a struct, int, dynamic array data or whatever.Sounds nice. Just curious -- what is it you require from dmd 1.10?dmd 1.10 provides std.gc.capacity, which can tell you if a block of memory is allocated by the gc. I use this to check if a delegates comes from an object (with the .ptr property), in which case the signals hooks a delegate with notifyRegister on the object which is called on destruction for auto disconnection. I should have documented this btw.
Mar 28 2007