[phobos] Improving std.signals

Johannes Pfau johannespfau at googlemail.com
Sun Oct 10 02:07:31 PDT 2010


 On 09.10.2010 23:20, Robert Jacques wrote:
> On Sat, 09 Oct 2010 14:48:29 -0400, Sean Kelly
> <sean at invisibleduck.org> wrote:
>> What are the limitations of this for multithreaded use and
>> reentrancy?  Can I modify the handler list from within a handler, etc?
>
> Delegates as currently not safe for multithreaded use as delegate
> modifiers (pure, shared, immutable, etc) don't work yet, IIRC. The
> library appears to be designed for signal thread use only. Currently,
> modifying the handler list from within a handler would result in
> undefined behavior.
Like the old implementation this implementation doesn't support
multithreaded use (yet). I thought about it a little and I think making
it thread safe using mutexes shouldn't be hard. I know message passing
is supposed to be used whenever possible, but I don't think it works
well in this case.

With the new implementation SList is used internally. SLists
stableInsertAfter and stableLinearRemove do not invalidate ranges, so at
least for single thread use modifying the handler list from within a
handler should be fine. The emit call's reentrancy depends on SLists
opSlice reentrancy, but I guess it is reentrant.

If delegate modifiers really don't work yet, this could be a problem.

-- 
Johannes Pfau



More information about the phobos mailing list