Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
December 04, 2004 Threading in D? | ||||
---|---|---|---|---|
| ||||
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 Re: Threading in D? | ||||
---|---|---|---|---|
| ||||
Posted in reply to mclysenk | "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 Re: Threading in D? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ben Hinkle | 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 Re: Threading in D? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean Kelly | > 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 Re: Threading in D? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ben Hinkle | 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 |
Copyright © 1999-2021 by the D Language Foundation