lock keyword needs to support condition variables!
Submitted by Adam B
Link to original bug (#624023)
Description
In my mind, mutexes and condition variables are a team (they work together). I'd guess that at least 50% of the threading code I've ever written involves condition variables.
Vala nicely wraps the semantics of a mutex with the lock keyword:
lock (foo) { foo.update(); }
The great thing about 'lock' as opposed to GLib.Mutex is that it's exception-safe and recursive. This makes me really want to use 'lock'. However, I cannot, if I need a condition variable (GLib.Cond):
lock (foo) { myConditionVariable.wait(???); //Cond.wait requires a locked GLib.Mutex object! }
Cond.wait requires a locked GLib.Mutex object as a parameter and I have no way to get at it from Vala (although, looking at the generated C code I can see it has one).
Perhaps the Vala compiler could be "smart" and support this:
lock (foo) { myConditionVariable.wait(foo); //compiler figures it out }
Version: 0.9.x