aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Thread/Mutex.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2024-03-18 22:39:59 -0700
committerAndrew Kelley <andrew@ziglang.org>2024-03-19 11:45:09 -0700
commitcd62005f19ff966d2c42de4daeb9a1e4b644bf76 (patch)
tree4bb316708afaf79c971808df792d8fe86274789b /lib/std/Thread/Mutex.zig
parent7057bffc14602add697eb566b83934b7ad3fd81c (diff)
downloadzig-cd62005f19ff966d2c42de4daeb9a1e4b644bf76.tar.gz
zig-cd62005f19ff966d2c42de4daeb9a1e4b644bf76.zip
extract std.posix from std.os
closes #5019
Diffstat (limited to 'lib/std/Thread/Mutex.zig')
-rw-r--r--lib/std/Thread/Mutex.zig21
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/std/Thread/Mutex.zig b/lib/std/Thread/Mutex.zig
index 67472ffd9c..b6d3d6fb84 100644
--- a/lib/std/Thread/Mutex.zig
+++ b/lib/std/Thread/Mutex.zig
@@ -23,7 +23,6 @@ const std = @import("../std.zig");
const builtin = @import("builtin");
const Mutex = @This();
-const os = std.os;
const assert = std.debug.assert;
const testing = std.testing;
const Thread = std.Thread;
@@ -117,36 +116,40 @@ const SingleThreadedImpl = struct {
// SRWLOCK on windows is almost always faster than Futex solution.
// It also implements an efficient Condition with requeue support for us.
const WindowsImpl = struct {
- srwlock: os.windows.SRWLOCK = .{},
+ srwlock: windows.SRWLOCK = .{},
fn tryLock(self: *@This()) bool {
- return os.windows.kernel32.TryAcquireSRWLockExclusive(&self.srwlock) != os.windows.FALSE;
+ return windows.kernel32.TryAcquireSRWLockExclusive(&self.srwlock) != windows.FALSE;
}
fn lock(self: *@This()) void {
- os.windows.kernel32.AcquireSRWLockExclusive(&self.srwlock);
+ windows.kernel32.AcquireSRWLockExclusive(&self.srwlock);
}
fn unlock(self: *@This()) void {
- os.windows.kernel32.ReleaseSRWLockExclusive(&self.srwlock);
+ windows.kernel32.ReleaseSRWLockExclusive(&self.srwlock);
}
+
+ const windows = std.os.windows;
};
// os_unfair_lock on darwin supports priority inheritance and is generally faster than Futex solutions.
const DarwinImpl = struct {
- oul: os.darwin.os_unfair_lock = .{},
+ oul: c.os_unfair_lock = .{},
fn tryLock(self: *@This()) bool {
- return os.darwin.os_unfair_lock_trylock(&self.oul);
+ return c.os_unfair_lock_trylock(&self.oul);
}
fn lock(self: *@This()) void {
- os.darwin.os_unfair_lock_lock(&self.oul);
+ c.os_unfair_lock_lock(&self.oul);
}
fn unlock(self: *@This()) void {
- os.darwin.os_unfair_lock_unlock(&self.oul);
+ c.os_unfair_lock_unlock(&self.oul);
}
+
+ const c = std.c;
};
const FutexImpl = struct {