std.signals2 proposal
Kagamin
spam at here.lot
Thu Nov 8 10:26:56 PST 2012
On Wednesday, 7 November 2012 at 23:26:46 UTC, eskimo wrote:
> Well I don't think it is a common pattern to create an object,
> connect
> it to some signal and drop every reference to it.
Ok, example: suppose we have a tabbed interface and on closing a
tab we want to free model data, displayed in the tab and we
already have standard IDisposable.Dispose() method, so:
_tab.closed.connect((sender,args)=>this.Dispose());
If the closure dies prematurely, it won't free resources at all
or at the right time. Although you currently keep a strong
reference to closures, you claim it's a bug rather than feature.
You fix deterministic sloppiness of memory leaks at the cost of
undeterministic sloppiness of prematurely dying event handlers
(depending on the state of the heap).
More information about the Digitalmars-d
mailing list