Creating a shared reference type
Minas Mina
minas_mina1990 at hotmail.co.uk
Fri Jul 13 16:10:46 PDT 2012
I'm want to "play" a bit with thread syncronization...
So this is a (big) part of my code. The other is the imports, the
thread starting and the printing of x.
shared int x;
shared Semaphore sema;
void main(string[] args)
{
auto t1 = new Thread(&f);
auto t2 = new Thread(&g);
sema = new Semaphore(1); // error here
The error is: Error: cannot implicitly convert expression (new
Semaphore(1u)) of type core.sync.semaphore.Semaphore to
shared(Semaphore)
I understand what the error means, I just don't know how to fix
it (to make it explicit). I tried new shared (Semaphore(1)) but
doesn't work.
More information about the Digitalmars-d-learn
mailing list