aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Thread.zig
diff options
context:
space:
mode:
authorprotty <45520026+kprotty@users.noreply.github.com>2022-04-23 19:35:56 -0500
committerGitHub <noreply@github.com>2022-04-23 19:35:56 -0500
commit963ac60918b39cafdda3cb99eff4cd9d20edd839 (patch)
tree8b480e6c1c01c11758f47b1126c53e75a339d1a1 /lib/std/Thread.zig
parentdaef82d06fd6b30d2cab7f5a6723cf2e3c7b48c6 (diff)
downloadzig-963ac60918b39cafdda3cb99eff4cd9d20edd839.tar.gz
zig-963ac60918b39cafdda3cb99eff4cd9d20edd839.zip
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
Diffstat (limited to 'lib/std/Thread.zig')
-rw-r--r--lib/std/Thread.zig27
1 files changed, 1 insertions, 26 deletions
diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig
index e28471d6b3..db7117fdd7 100644
--- a/lib/std/Thread.zig
+++ b/lib/std/Thread.zig
@@ -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();
-}