Thread overview
Threading in D?
Dec 04, 2004
mclysenk
Dec 04, 2004
Ben Hinkle
Dec 04, 2004
Sean Kelly
Dec 05, 2004
Ben Hinkle
Dec 05, 2004
Sean Kelly
December 04, 2004
What sort of synchronization mechanisms does D provide for multiple threads?  Is there any standard implementation of structures like locks / memory barriers? Java has the methods wait() and notify() built in each object, and C/C++ has many libraries which can get the job done.  What is there in D/Phobos?


December 04, 2004
"mclysenk" <mclysenk_member@pathlink.com> wrote in message news:cordtd$fbo$1@digitaldaemon.com...
> What sort of synchronization mechanisms does D provide for multiple
> threads?  Is
> there any standard implementation of structures like locks / memory
> barriers?
> Java has the methods wait() and notify() built in each object, and C/C++
> has
> many libraries which can get the job done.  What is there in D/Phobos?
>
>

The D language has basic critical section support using the "synchronized"
statement or attribute. It doesn't have wait/notify or other types of locks.
The "volatile" statement is for memory barriers.
A port of the Java 1.5 concurrency classes is available at
http://home.comcast.net/~benhinkle/mintl/locks.html
It has a reentrant lock with condition variables, countdown, cyclic-barrier,
exchanger, semaphore and a read-write lock.

-Ben


December 04, 2004
In article <cot4e8$2s7u$1@digitaldaemon.com>, Ben Hinkle says...
>
>
>"mclysenk" <mclysenk_member@pathlink.com> wrote in message news:cordtd$fbo$1@digitaldaemon.com...
>> What sort of synchronization mechanisms does D provide for multiple
>> threads?  Is
>> there any standard implementation of structures like locks / memory
>> barriers?
>> Java has the methods wait() and notify() built in each object, and C/C++
>> has
>> many libraries which can get the job done.  What is there in D/Phobos?
>>
>>
>
>The D language has basic critical section support using the "synchronized"
>statement or attribute. It doesn't have wait/notify or other types of locks.
>The "volatile" statement is for memory barriers.
>A port of the Java 1.5 concurrency classes is available at
>http://home.comcast.net/~benhinkle/mintl/locks.html
>It has a reentrant lock with condition variables, countdown, cyclic-barrier,
>exchanger, semaphore and a read-write lock.

Note that "synchronized" just indicates that the compiler should not optimize past those barriers.  AFAIK there are currently no hardware-level barrier instructions in place, so lockless synchronization methods make a handy supplement.


Sean


December 05, 2004
> Note that "synchronized" just indicates that the compiler should not optimize

I think you meant "volatile" instead of "synchronized", yes?

> past those barriers.  AFAIK there are currently no hardware-level barrier instructions in place, so lockless synchronization methods make a handy supplement.
>
>
> Sean
>
> 


December 05, 2004
In article <cotr0v$m1l$1@digitaldaemon.com>, Ben Hinkle says...
>
>> Note that "synchronized" just indicates that the compiler should not optimize
>
>I think you meant "volatile" instead of "synchronized", yes?

Oops.  Yes I did.  That's what I get for posting before having my morning coffee.


Sean