digitalmars.D - std.signals non-object delegates
- Jacob Shtokolov (21/21) Jun 07 2018 Hello,
- Jacob Shtokolov (5/9) Jun 12 2018 5 days passed and no one answered 😒
- Steven Schveighoffer (16/27) Jun 12 2018 I'll respond to say that I don't know a lot of people who use signals
- Jacob Shtokolov (8/28) Jun 12 2018 Thank you Steve!
- Zoadian (7/16) Jun 12 2018 i remember someone was working on a std.signals replacement a few
- Jacob Shtokolov (3/22) Jun 12 2018 Many thanks! I didn't see this topic at all. This is very
Hello, I'd like to start a discussion about the standard std.signals library. Currently it has a strange limitation - you can't pass delegates that don't belong to an object. I reviewed the source code an came to conclusion that it can be easily fixed. However, the thing that concerns me more is how to deal with delegates whose allocated frame pointer (context) was disposed by GC. In the case of object's delegate, the library places dispose handlers via the `rt_attachDisposeEvent`, so if GC just freed an object, all related callbacks will be unregistered automatically. But I'm not really sure how to do the same for a bare frame pointer. I'd like to attract some attention to this topic, because I see that people tend to re-implement the same functionality over and over again in their projects. For example, look at the DLangUI by Vadim Lopatin: https://github.com/buggins/dlangui/blob/master/src/dlangui/core/signals.d - the same functionality, but without this stupid limitation (in terms of user experience). Any suggestions?
Jun 07 2018
On Thursday, 7 June 2018 at 12:56:55 UTC, Jacob Shtokolov wrote:Hello, I'd like to start a discussion about the standard std.signals library. [...]5 days passed and no one answered 😒 Maybe the guys who are contributing to DRuntime could answer: is that possible to attach GC dispose event handlers to the delegate context?
Jun 12 2018
On 6/12/18 9:04 AM, Jacob Shtokolov wrote:On Thursday, 7 June 2018 at 12:56:55 UTC, Jacob Shtokolov wrote:I'll respond to say that I don't know a lot of people who use signals and slots. It's a very old part of Phobos, and I think a lot of people here aren't familiar with it.Hello, I'd like to start a discussion about the standard std.signals library. [...]5 days passed and no one answered 😒Maybe the guys who are contributing to DRuntime could answer: is that possible to attach GC dispose event handlers to the delegate context?I've never heard of this functionality. Looking it up, it's not used anywhere in druntime, only from phobos, and only from this std.signals implementation (literally a search through all code finds the function rt_attachDisposeEvent in 2 places -- the definition, and the one usage in std.signals). Looking at the implementation, it depends on having an Object with a Monitor, as the event is stored in the monitor. So you couldn't attach it to any specific piece of memory, it HAS to be an Object. But like I said, it's not used pretty much anywhere. So I think nobody would miss it if you ripped it out and made it better :) feel free to open a bug report and/or PR and get some more discussion going. -Steve
Jun 12 2018
On Tuesday, 12 June 2018 at 14:33:57 UTC, Steven Schveighoffer wrote:On 6/12/18 9:04 AM, Jacob Shtokolov wrote:Thank you Steve! Then I'll try to fire a bug report and propose my own solution to this problem. Probably there is no need to track down the non-object dispose events. Good to hear that not so many people are affected by this 😏[...]I'll respond to say that I don't know a lot of people who use signals and slots. It's a very old part of Phobos, and I think a lot of people here aren't familiar with it.[...]I've never heard of this functionality. Looking it up, it's not used anywhere in druntime, only from phobos, and only from this std.signals implementation (literally a search through all code finds the function rt_attachDisposeEvent in 2 places -- the definition, and the one usage in std.signals). Looking at the implementation, it depends on having an Object with a Monitor, as the event is stored in the monitor. So you couldn't attach it to any specific piece of memory, it HAS to be an Object. But like I said, it's not used pretty much anywhere. So I think nobody would miss it if you ripped it out and made it better :) feel free to open a bug report and/or PR and get some more discussion going. -Steve
Jun 12 2018
On Tuesday, 12 June 2018 at 15:21:49 UTC, Jacob Shtokolov wrote:On Tuesday, 12 June 2018 at 14:33:57 UTC, Steven Schveighoffer wrote:i remember someone was working on a std.signals replacement a few years ago. don't know where that went. it might be this: https://wiki.dlang.org/Review/std.signal https://github.com/phobos-x/phobosx/blob/master/source/phobosx/signal.d[...]Thank you Steve! Then I'll try to fire a bug report and propose my own solution to this problem. Probably there is no need to track down the non-object dispose events. Good to hear that not so many people are affected by this 😏
Jun 12 2018
On Tuesday, 12 June 2018 at 15:39:52 UTC, Zoadian wrote:On Tuesday, 12 June 2018 at 15:21:49 UTC, Jacob Shtokolov wrote:Many thanks! I didn't see this topic at all. This is very helpful, will try to check this implementation.On Tuesday, 12 June 2018 at 14:33:57 UTC, Steven Schveighoffer wrote:i remember someone was working on a std.signals replacement a few years ago. don't know where that went. it might be this: https://wiki.dlang.org/Review/std.signal https://github.com/phobos-x/phobosx/blob/master/source/phobosx/signal.d[...]Thank you Steve! Then I'll try to fire a bug report and propose my own solution to this problem. Probably there is no need to track down the non-object dispose events. Good to hear that not so many people are affected by this 😏
Jun 12 2018