Shared keyword and the GC?
sclytrack
sclytrack at answermyself.com
Fri Oct 19 04:39:56 PDT 2012
On Friday, 19 October 2012 at 09:07:55 UTC, sclytrack wrote:
>
>> How does it deal with the problem where a pointer in TLS
>> points to global data,
>
> Need to run stop-the-world for shared heap. But it would be
> interesting to have blocks that have no shared pointers in them.
>
>
>> or worse yet, a pointer in the global heap points to TLS?
>>
>
> Could you give an example?
>
import std.stdio;
class Local
{
}
class Global
{
Local data;
int [] arr;
}
Local l2;
int [] arr; //tls
int main()
{
shared Global g = new shared(Global); //global heap
Local l1 = new Local(); //future local heap
// g.data = l1; //disallowed
l2 = new Local();
// g.data = l2; //disallowed
arr = new int[10]; //future local heap
g.arr = cast(shared(int[])) arr; //bypassed.
writeln("Complete");
return 0;
}
More information about the Digitalmars-d
mailing list