digitalmars.D.announce - phobosx.signal ready
- Robert (47/47) Jul 15 2013 phobosx.signal ready
- David (1/1) Jul 17 2013 Thanks for your work, I'll try to test it the next days!
- Robert (4/5) Jul 18 2013 Thanks! I really appreciate it. The more real world use, the
- Zoadian (2/2) Jul 17 2013 Thank you very much!
- Zoadian (3/3) Jul 17 2013 you might run into
- Zoadian (6/6) Jul 17 2013 I'm also running into
- John Colvin (3/4) Jul 17 2013 Not gonna happen as it's not a forum, it's just a forum interface
- Robert (4/10) Jul 18 2013 Thanks for pointing out those issues! I added a link to them to
- Robert (8/10) Jul 18 2013 You are very welcome. I am glad to see some feedback, I was
- E.S. Quinn (5/5) Jul 17 2013 Out of curiosity, does this implementation support e.g. function
- Robert (7/12) Jul 18 2013 I just improved the example given in the docs, see the code after
- John Colvin (3/15) Jul 18 2013 Your site gives me an ssl certificate error with https and a 504
- Robert (5/7) Jul 18 2013 Yeah :-) It is only a home server, I did not pay for a proper
- Brad Anderson (2/9) Jul 23 2013 You can get free certificates from StartSSL.
- Robert (3/4) Jul 24 2013 Thanks, that's actually cool :-) Unfortunately it does not work
- David (17/17) Jul 21 2013 Ok, I came around to test it, finally.
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
Jul 15 2013
On Wednesday, 17 July 2013 at 16:06:14 UTC, David wrote:Thanks for your work, I'll try to test it the next days!Thanks! I really appreciate it. The more real world use, the better and the sooner it can be moved to phobos! I am going to fix any found issues ASAP.
Jul 18 2013
Thank you very much! i might finally get rid of all those segfaults now :)
Jul 17 2013
you might run into http://d.puremagic.com/issues/show_bug.cgi?id=10260 drop the -profile switch to make it work
Jul 17 2013
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!
Jul 17 2013
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.
Jul 17 2013
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 ;-)
Jul 18 2013
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
Jul 18 2013
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.
Jul 17 2013
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
Jul 18 2013
On Thursday, 18 July 2013 at 08:44:39 UTC, Robert wrote:On Thursday, 18 July 2013 at 01:26:17 UTC, E.S. Quinn wrote:Your site gives me an ssl certificate error with https and a 504 with httpOut 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
Jul 18 2013
Your site gives me an ssl certificate error with https and a 504 with httpYeah :-) It is only a home server, I did not pay for a proper certificate. Just ignore the security warning. I merely wanted to publish the documentation somewhere for easier access. Best regards, Robert
Jul 18 2013
On Thursday, 18 July 2013 at 11:31:06 UTC, Robert wrote:You can get free certificates from StartSSL.Your site gives me an ssl certificate error with https and a 504 with httpYeah :-) It is only a home server, I did not pay for a proper certificate. Just ignore the security warning. I merely wanted to publish the documentation somewhere for easier access. Best regards, Robert
Jul 23 2013
You can get free certificates from StartSSL.Thanks, that's actually cool :-) Unfortunately it does not work for my dyndns domain. (I can't register vhios.dyndns.org, only dyndns.org would be accepted)
Jul 24 2013
Ok, I came around to test it, finally. A few things: * I don't like the separation between connect/strongConnect * I would like to bind a strongConnect to a class, if the class is gone the strongConnect should be gone, too. E.g. "window.single_key_down[JUMP].strongConnect({ physics.jump(); });" physics is a class variable, this will blow up once the class holding it is gone * I don't like the connect api for class-method connects, I write all the time "window.on_mouse_pos.connect!"on_mouse_pos"(this);" (the this is kinda annoying), doesn't something like signal.connect!(bla)() work, with an alias template param? * Why is there no convenience class for Signal? Since the copy constructor is disabled, I have to use a pointer, not a big deal, but a class would be more convenient. Other than that! Great job, I had not a single segfault so far (only 3 "starts" so far though :>)
Jul 21 2013
A few things: * I don't like the separation between connect/strongConnectIt should be possible to make strongConnect just another overload of connect, but I chose to use another name because of the changed semantics. This way both the writer and the reader of the code have a clue what is going on. If strongConnect was also called connect, you could easily choose a strong connection by accident: sig.connect(&o.watch); // Oops strong connect.* I would like to bind a strongConnect to a class, if the class is gone the strongConnect should be gone, too. E.g. "window.single_key_down[JUMP].strongConnect({ physics.jump(); });" physics is a class variable, this will blow up once the class holding it is goneIf physics is on the GC collected heap - nothing is going to blow up. The signal just keeps a strong ref to physics so the GC won't free it. If physics is for example reference counted or its lifetime is managed manually then it would blow up if you forget to call disconnect before destroying the object. It would be easier if you used connect instead of strongConnect, this way the connection is dropped whenever physics gets destroyed, whatever the cause is. Also the signal won't keep it alive. If you really mean a class by 'class variable' than it can't really be gone, except maybe for dynamic linking. In this case you would have to manage your connections yourself.* I don't like the connect api for class-method connects, I write all the time "window.on_mouse_pos.connect!"on_mouse_pos"(this);" (the this is kinda annoying), doesn't something like signal.connect!(bla)() work, with an alias template param?Unfortunately I don't see how this could work, but I am open for suggestions.* Why is there no convenience class for Signal? Since the copy constructor is disabled, I have to use a pointer, not a big deal, but a class would be more convenient.Not sure about this. It would just be a wrapper doing nothing except forwarding function calls, is this really better: auto sig = new SignalWrapper!(int)(); void func(SignalWrapper!int sig) {} than auto sig = new Signal!(int)(); void func(Signal!int* sig) {} ?Other than that! Great job, I had not a single segfault so far (only 3 "starts" so far though :>):-)
Jul 24 2013
On Sunday, 21 July 2013 at 11:24:42 UTC, David wrote:"window.single_key_down[JUMP].strongConnect({ physics.jump(); });" physics is a class variable, this will blow up once the class holding it is goneYou ask for the weak ref semantics, but as the name suggests, strongConnect has the strong ref semantics. In this case the closure keep a strong ref to the object with the physics field and the signal keeps a strong ref to the closure, so the window keeps a strong ref to the object, so it won't be collected.
Jul 28 2013
Am 28.07.2013 18:39, schrieb Kagamin:On Sunday, 21 July 2013 at 11:24:42 UTC, David wrote:Yeah I noticed that shortly after I wrote that... the "connect" method should just work."window.single_key_down[JUMP].strongConnect({ physics.jump(); });" physics is a class variable, this will blow up once the class holding it is goneYou ask for the weak ref semantics, but as the name suggests, strongConnect has the strong ref semantics. In this case the closure keep a strong ref to the object with the physics field and the signal keeps a strong ref to the closure, so the window keeps a strong ref to the object, so it won't be collected.
Jul 28 2013