Something needs to happen with shared, and soon.
Benjamin Thaut
code at benjamin-thaut.de
Wed Nov 14 01:23:57 PST 2012
Am 14.11.2012 10:18, schrieb Walter Bright:
> On 11/14/2012 1:01 AM, Benjamin Thaut wrote:
>> I still don't agree with you there. The struct would have clearly
>> outlived any
>> thread (as it was in the global scope) so at the point where it is
>> destroyed
>> there should be really only one thread left. So it IS destroyed in a
>> single
>> threaded context.
>
> If you know this for a fact, then cast it to thread local. The compiler
> cannot figure this out for you, hence it issues the error.
>
>
>> The same is done for classes by the GC just that the GC
>> ignores shared altogether.
>
> That's different, because the GC verifies that there are *no* references
> to it from any thread first.
Could you please give an example where it would break?
And whats the difference between:
struct Value
{
~this()
{
printf("destroy\n");
}
}
shared Value v;
and:
shared static ~this()
{
printf("destory\n");
}
Kind Regards
Benjamin Thaut
More information about the Digitalmars-d
mailing list