Commit d525198d authored by Marcus Comstedt's avatar Marcus Comstedt

Thread.Condition: Provide fallback implementation

This is needed by Stdio.FakePipe.
parent 8a93f9b3
......@@ -1156,6 +1156,38 @@ class Mutex
locks++;
return MutexKey (dec_locks);
}
Condition condition ()
{
return Condition(this);
}
}
// Fallback implementation of Thread.Condition.
class Condition (protected Mutex|void mutex)
{
variant void wait(MutexKey key, void|int|float seconds)
{
if (!seconds) {
// To be really accurate we should hang now, but somehow
// that doesn't seem too useful.
error ("Deadlock detected.\n");
}
sleep(seconds);
}
variant void wait(MutexKey key, int seconds, int nanos)
{
wait(key, seconds + nanos*1e-9);
}
void signal()
{
}
void broadcast()
{
}
}
// Fallback implementation of Thread.Fifo.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment