I have thread. It locks up. If I changed from a bool val it is using from shared to __gshared it works. I checked the address inside and outside of the thread and they are different for shared and same for __gshared.

I thought shared was essentially __gshared with additional semantics? That a shared variable was the same across all threads?

The only difference is that the thread is a windows CreateThread. I guess D doesn't know about such threads and hence shared doesn't extend across to them?

If so, the docs should be updated to mention this.

My code goes something like this:

struct WinThread
{
   shared bool isPaused = false;
   ...

   // Windows threaded callback uses isPaused
}


// use isPaused in main thread

// Crashes in WinThread on use expressions involving isPaused.

Checking pointers between the two shows they are different.

changing to _gshared gives the same address of isPaused for both threads.





Reply via email to