Thread overview | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
July 15, 2013 phobosx.signal ready | ||||
---|---|---|---|---|
| ||||
phobosx.signal ready I finished my std.signals2 implementation. I moved it to: https://github.com/phobos-x/phobosx/blob/master/source/phobosx/signal.d you can also find it in the dub registry: http://code.dlang.org/packages/phobosx Documentation: https://vhios.dyndns.org/signal.html I renamed it from std.signals2 to phobosx.signal. When included in phobos it will most likely be named std.signal. Improvements over std.signals: - No more heisenbugs (http://d.puremagic.com/issues/show_bug.cgi?id=4150) - safe connect method to an object's method (weak ref semantic) - support for indirect connect to an object's method via a wrapper delegate (weak ref semantics to target object) - strongConnect method for connecting to non objects. (strong ref semantics) - disconnect method for disconnecting all methods of a given object with a single call. - Proper exception handling. Meaning if a slot throws an exception the other slots will still be called and all slot exceptions are chained together. - signal methods are safe to call from within a slot. - signal copying is forbidden. While this implementation would not cause segfaults when copied like std.signals, it is not really clear how a signal should be copied in the general case. - Signals are implemented as structs instead of a mixin and every template parameter agnostic code also does not depend on the template parameters -> avoid template bloat. - Memory footprint for empty signal is even lower than the one of the current std.signals, which is important because many signals end up not being used at all. - Provided string mixin which allows only the containing class to issue emit(), but everyone to connect. - Slots are called in the same sequence as they were registered. I could not find any more bugs, so please use it and show me the bugs I missed :-) Have fun! Best regards, Robert |
July 17, 2013 Re: phobosx.signal ready | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert | Thanks for your work, I'll try to test it the next days! |
July 17, 2013 Re: phobosx.signal ready | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert | Thank you very much! i might finally get rid of all those segfaults now :) |
July 17, 2013 Re: phobosx.signal ready | ||||
---|---|---|---|---|
| ||||
Posted in reply to Zoadian | you might run into http://d.puremagic.com/issues/show_bug.cgi?id=10260 drop the -profile switch to make it work |
July 17, 2013 Re: phobosx.signal ready | ||||
---|---|---|---|---|
| ||||
Posted in reply to Zoadian | I'm also running into http://d.puremagic.com/issues/show_bug.cgi?id=10502 when using your mixin signal function. So I'm using Signal! directly now. Works well so far. Btw this forum needs an edit button! |
July 17, 2013 Re: phobosx.signal ready | ||||
---|---|---|---|---|
| ||||
Posted in reply to Zoadian | On Wednesday, 17 July 2013 at 19:38:54 UTC, Zoadian wrote:
> Btw this forum needs an edit button!
Not gonna happen as it's not a forum, it's just a forum interface to an NNTP newsgroup and mailing list.
|
July 18, 2013 Re: phobosx.signal ready | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert | Out of curiosity, does this implementation support e.g. function literals or nested functions with connect()? The current phobos implementation only allows connecting class methods, and that's a limitation I've bumped up against quite a bit, especially when writing test code. |
July 18, 2013 Re: phobosx.signal ready | ||||
---|---|---|---|---|
| ||||
Posted in reply to Zoadian | On Wednesday, 17 July 2013 at 19:38:54 UTC, Zoadian wrote:
> I'm also running into http://d.puremagic.com/issues/show_bug.cgi?id=10502 when using your mixin signal function.
>
> So I'm using Signal! directly now.
> Works well so far.
>
>
> Btw this forum needs an edit button!
Thanks for pointing out those issues! I added a link to them to the documentation for now. This does not fix anything of course, but at least one does not need to find out the hard way ;-)
|
July 18, 2013 Re: phobosx.signal ready | ||||
---|---|---|---|---|
| ||||
Posted in reply to Zoadian | On Wednesday, 17 July 2013 at 17:23:48 UTC, Zoadian wrote:
> Thank you very much!
> i might finally get rid of all those segfaults now :)
You are very welcome. I am glad to see some feedback, I was already afraid I did all the work and nobody uses it. I myself currently have no use case for signals in D, but I used them a lot in C++ and found the D implementation not quite satisfying, so I had to improve it.
Best regards,
Robert
|
July 18, 2013 Re: phobosx.signal ready | ||||
---|---|---|---|---|
| ||||
Posted in reply to E.S. Quinn | On Thursday, 18 July 2013 at 01:26:17 UTC, E.S. Quinn wrote: > Out of curiosity, does this implementation support e.g. function literals or nested functions with connect()? The current phobos implementation only allows connecting class methods, and that's a limitation I've bumped up against quite a bit, especially when writing test code. I just improved the example given in the docs, see the code after comment '//Do some fancy stuff'. It should answer your question. ;-) https://vhios.dyndns.org/signal.html Best regards, Robert |
Copyright © 1999-2021 by the D Language Foundation