diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2025-01-17 01:20:11 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-17 01:20:11 -0500 |
| commit | 4bace0f6212a3007247c42b0effcc40c6cfe61a8 (patch) | |
| tree | a5c1fee87a9266319d8ceffa7717ca5c70b61f7b /lib/std/Thread | |
| parent | 257054a1467b2612725bd66852d84496024cf66c (diff) | |
| parent | 8c8dfb35f398407319764f0f8998de34c5247ed6 (diff) | |
| download | zig-4bace0f6212a3007247c42b0effcc40c6cfe61a8.tar.gz zig-4bace0f6212a3007247c42b0effcc40c6cfe61a8.zip | |
Merge pull request #22386 from jacobly0/x86_64-rewrite
x86_64: begin rewriting instruction selection
Diffstat (limited to 'lib/std/Thread')
| -rw-r--r-- | lib/std/Thread/Condition.zig | 6 | ||||
| -rw-r--r-- | lib/std/Thread/Mutex.zig | 2 | ||||
| -rw-r--r-- | lib/std/Thread/Pool.zig | 6 |
3 files changed, 9 insertions, 5 deletions
diff --git a/lib/std/Thread/Condition.zig b/lib/std/Thread/Condition.zig index e6c25d761c..65bfa32ad0 100644 --- a/lib/std/Thread/Condition.zig +++ b/lib/std/Thread/Condition.zig @@ -161,17 +161,17 @@ const WindowsImpl = struct { } } - if (comptime builtin.mode == .Debug) { + if (builtin.mode == .Debug) { // The internal state of the DebugMutex needs to be handled here as well. mutex.impl.locking_thread.store(0, .unordered); } const rc = os.windows.kernel32.SleepConditionVariableSRW( &self.condition, - if (comptime builtin.mode == .Debug) &mutex.impl.impl.srwlock else &mutex.impl.srwlock, + if (builtin.mode == .Debug) &mutex.impl.impl.srwlock else &mutex.impl.srwlock, timeout_ms, 0, // the srwlock was assumed to acquired in exclusive mode not shared ); - if (comptime builtin.mode == .Debug) { + if (builtin.mode == .Debug) { // The internal state of the DebugMutex needs to be handled here as well. mutex.impl.locking_thread.store(std.Thread.getCurrentId(), .unordered); } diff --git a/lib/std/Thread/Mutex.zig b/lib/std/Thread/Mutex.zig index be421c4c94..402c96a4d5 100644 --- a/lib/std/Thread/Mutex.zig +++ b/lib/std/Thread/Mutex.zig @@ -158,7 +158,7 @@ const FutexImpl = struct { // On x86, use `lock bts` instead of `lock cmpxchg` as: // - they both seem to mark the cache-line as modified regardless: https://stackoverflow.com/a/63350048 // - `lock bts` is smaller instruction-wise which makes it better for inlining - if (comptime builtin.target.cpu.arch.isX86()) { + if (builtin.target.cpu.arch.isX86()) { const locked_bit = @ctz(locked); return self.state.bitSet(locked_bit, .acquire) == 0; } diff --git a/lib/std/Thread/Pool.zig b/lib/std/Thread/Pool.zig index 86bac7ce46..874050a35f 100644 --- a/lib/std/Thread/Pool.zig +++ b/lib/std/Thread/Pool.zig @@ -27,6 +27,7 @@ pub const Options = struct { allocator: std.mem.Allocator, n_jobs: ?usize = null, track_ids: bool = false, + stack_size: usize = std.Thread.SpawnConfig.default_stack_size, }; pub fn init(pool: *Pool, options: Options) !void { @@ -54,7 +55,10 @@ pub fn init(pool: *Pool, options: Options) !void { errdefer pool.join(spawned); for (pool.threads) |*thread| { - thread.* = try std.Thread.spawn(.{}, worker, .{pool}); + thread.* = try std.Thread.spawn(.{ + .stack_size = options.stack_size, + .allocator = allocator, + }, worker, .{pool}); spawned += 1; } } |
