11/15/2012 1:06 AM, Walter Bright пишет:
On 11/14/2012 3:14 AM, Benjamin Thaut wrote:
A small code example which would break as soon as we allow destructing
of shared
value types would really be nice.

I hate to repeat myself, but:

Thread 1:
     1. create shared object
     2. pass reference to that object to Thread 2
     3. destroy object

Thread 2:
     1. manipulate that object

Ain't structs typically copied anyway?

Reference would imply pointer then. If the struct is on the stack (weird but could be) then the thread that created it destroys the object once. The thing is as unsafe as escaping a pointer is.

Personally I think that shared stuff allocated on the stack is here-be-dragons @system code in any case.

Otherwise it's GC's responsibility to destroy heap allocated struct when there are no references to it.

What's so puzzling about it?

BTW currently GC-allocated structs are not having their destructor called at all. The bug is however _minor_ ...

http://d.puremagic.com/issues/show_bug.cgi?id=2834

--
Dmitry Olshansky

Reply via email to