shared not working!

Hiemlick Hiemlicker via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jul 3 22:16:14 PDT 2016


On Monday, 4 July 2016 at 05:08:34 UTC, ag0aep6g wrote:
> On 07/04/2016 01:20 AM, Hiemlick Hiemlicker wrote:
>> 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.
>>
> [...]
>>     shared bool isPaused = false;
>
> Needs to be static shared. __gshared implies static, shared 
> doesn't.

But static isn't per instance, is it?

That means every thread created will have the same value of 
Paused. Calling Pause will pause all threads. That can't be right.

Shared should have no implication of static. If that was the 
case, all shared types would be static, would make them uses to 
have and to use a this.

Unless static shared is different than static + shared?





More information about the Digitalmars-d-learn mailing list