Re: Implementing a Monitor

2012-07-31 Thread Minas
Thank you for your reply. I have some more questions: I simplified my example. Now my monitor is used for mutual exclusion, to understand how monitors work first. // 3 threads are running P() - the main thread is not one of them void P() { while( run ) {

Re: Implementing a Monitor

2012-07-30 Thread Sean Kelly
You need to lock the mutex to synchronize access to the shared data. On Jul 27, 2012, at 2:31 PM, Minas Mina minas_mina1...@hotmail.co.uk wrote: class Monitor { Cond cond; Mutex mutex; char[] buffer; ulong sz; this() {

Implementing a Monitor

2012-07-27 Thread Minas Mina
I'm using condition variables to implement a monitor that simulates the producer-consumer(unbounded buffer) scenario. Note: monitor is __gshared and is initialized in main(). Then the other threads are created and run. There is one producer thread, and 5 consumer threads. void producer() {