Am 13.10.2013 09:47, schrieb Denis Shelomovskij:
--- Proposal ---

The proposal is to add weak reference functionality based on
`unstd.memory.weakref`. It can be placed e.g. in `core.memory`.

Source code:
https://bitbucket.org/denis-sh/unstandard/src/HEAD/unstd/memory/weakref.d
Documentation:
http://denis-sh.bitbucket.org/unstandard/unstd.memory.weakref.html
Enhancement request: http://d.puremagic.com/issues/show_bug.cgi?id=4151

+1

Bikeshed: I'd use "lock()" instead of "@property target()" based on precedence in the form of C++'s weak_ptr, but in general that should be a very valuable (and long overdue) addition.

Just to reassure, the following race-condition doesn't exist, right? It looks like "GC.addRoot()" makes guarantees by taking the GC lock or something similar?

         time ->
thread1: GC collection |               | run finalizer |
thread2: paused        | lock weak ref |               | access object

Reply via email to