I would like to propose the addition of condition variables to the language, or 
at least to the standard library. They complement the current monitor's mutex 
very well, are only allocated when needed and can even be part of the base 
Object class.

I've included the basic implementation i currently use on the language runtime 
I am working on in my spare time (which is a fork of phobos from about a year 
ago). It supports vista and posix so far, although I didn't test the posix one 
yet.

The included file also contains a working unittest with sample usage.

Here is what I added to my Object declaration for even more convenience:
---
abstract class Object {
        // [...]

        synchronized void Wait(uint interval = -1) {
                (cast(Monitor*)this.__monitor).Wait(interval);
        }
        synchronized void Notify() {
                (cast(Monitor*)this.__monitor).Notify();
        }
        synchronized void NotifyAll() {
                (cast(Monitor*)this.__monitor).NotifyAll();
        }
}

private import dlib.Monitor;
---

Attachment: Monitor.d
Description: Binary data

Reply via email to