std.Thread: Mutex and Condition improvements (#11497)
* Thread: minor cleanups * Thread: rewrite Mutex * Thread: introduce Futex.Deadline * Thread: Condition rewrite + cleanup * Mutex: optimize lock fast path * Condition: more docs * Thread: more mutex + condition docs * Thread: remove broken Condition test * Thread: zig fmt * address review comments + fix Thread.DummyMutex in GPA * Atomic: disable bitRmw x86 inline asm for stage2 * GPA: typo mutex_init * Thread: remove noalias on stuff * Thread: comment typos + clarifications
This commit is contained in:
@@ -459,9 +459,8 @@ const UnsupportedImpl = struct {
|
||||
}
|
||||
|
||||
fn unsupported(unusued: anytype) noreturn {
|
||||
@compileLog("Unsupported operating system", target.os.tag);
|
||||
_ = unusued;
|
||||
unreachable;
|
||||
@compileError("Unsupported operating system " ++ @tagName(target.os.tag));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1188,27 +1187,3 @@ test "Thread.detach" {
|
||||
event.wait();
|
||||
try std.testing.expectEqual(value, 1);
|
||||
}
|
||||
|
||||
fn testWaitForSignal(mutex: *Mutex, cond: *Condition) void {
|
||||
mutex.lock();
|
||||
defer mutex.unlock();
|
||||
cond.signal();
|
||||
cond.wait(mutex);
|
||||
}
|
||||
|
||||
test "Condition.signal" {
|
||||
if (builtin.single_threaded) return error.SkipZigTest;
|
||||
|
||||
var mutex = Mutex{};
|
||||
var cond = Condition{};
|
||||
|
||||
var thread: Thread = undefined;
|
||||
{
|
||||
mutex.lock();
|
||||
defer mutex.unlock();
|
||||
thread = try Thread.spawn(.{}, testWaitForSignal, .{ &mutex, &cond });
|
||||
cond.wait(&mutex);
|
||||
cond.signal();
|
||||
}
|
||||
thread.join();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user