Skip to content
Snippets Groups Projects
Commit 4515c00a authored by Marcus Comstedt's avatar Marcus Comstedt
Browse files

Thread.Condition: Backport fallback implementation from 8.1

This is needed by Concurrent.

Thread.Condition: Fix edge case in fallback implementation
parent 2283942e
No related branches found
No related tags found
No related merge requests found
......@@ -1022,6 +1022,38 @@ optional 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 || seconds == 0.0) {
// 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.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment