From a9667b5a859a589056f23df2b74b91fede0bbbfa Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 14 Jan 2021 20:41:37 -0700 Subject: organize std lib concurrency primitives and add RwLock * move concurrency primitives that always operate on kernel threads to the std.Thread namespace * remove std.SpinLock. Nobody should use this in a non-freestanding environment; the other primitives are always preferable. In freestanding, it will be necessary to put custom spin logic in there, so there are no use cases for a std lib version. * move some std lib files to the top level fields convention * add std.Thread.spinLoopHint * add std.Thread.Condition * add std.Thread.Semaphore * new implementation of std.Thread.Mutex for Windows and non-pthreads Linux * add std.Thread.RwLock Implementations provided by @kprotty --- src/ThreadPool.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ThreadPool.zig') diff --git a/src/ThreadPool.zig b/src/ThreadPool.zig index 1e91d3f731..ec580210e9 100644 --- a/src/ThreadPool.zig +++ b/src/ThreadPool.zig @@ -6,14 +6,14 @@ const std = @import("std"); const ThreadPool = @This(); -lock: std.Mutex = .{}, +lock: std.Thread.Mutex = .{}, is_running: bool = true, allocator: *std.mem.Allocator, workers: []Worker, run_queue: RunQueue = .{}, idle_queue: IdleQueue = .{}, -const IdleQueue = std.SinglyLinkedList(std.ResetEvent); +const IdleQueue = std.SinglyLinkedList(std.Thread.ResetEvent); const RunQueue = std.SinglyLinkedList(Runnable); const Runnable = struct { runFn: fn (*Runnable) void, -- cgit v1.2.3