authorgravatar for kbutcher6200@gmail.comkprotty <kbutcher6200@gmail.com> 2021-06-19 22:01:54-05:00
committergravatar for kbutcher6200@gmail.comkprotty <kbutcher6200@gmail.com> 2021-06-30 21:48:59-05:00
log235fcc5ba632ced7e972e1c8b133418c17cd7ab7
treef5d6607e972a3c256fe99dc2e665cda00da86c02
parent3a276be1355fe304c177bcc13a7896122801e5f2

std.Thread: another typo fix


1 files changed, 24 insertions(+), 24 deletions(-)

lib/std/Thread.zig+24-24
......@@ -25,6 +25,7 @@ pub const spinLoopHint = @compileError("deprecated: use std.atomic.spinLoopHint"
2525
2626pub const use_pthreads = target.os.tag != .windows and std.builtin.link_libc;
2727
28const Thread = @This();
2829const Impl = if (target.os.tag == .windows)
2930 WindowsThreadImpl
3031else if (use_pthreads)
......@@ -36,7 +37,6 @@ else
3637
3738impl: Impl,
3839
39
4040/// Represents a kernel thread handle.
4141/// May be an integer or a pointer depending on the platform.
4242/// On Linux and POSIX, this is the same as Id.
......@@ -120,6 +120,29 @@ pub fn spawn(
120120 return .{ .impl = impl };
121121}
122122
123/// Retrns the handle of this thread
124/// On Linux and POSIX, this is the same as Id.
125pub fn getHandle(self: Thread) Handle {
126 return self.impl.getHandle();
127}
128
129/// Release the obligation of the caller to call `join()` and have the thread clean up its own resources on completion.
130pub fn detach(self: Thread) void {
131 return self.impl.detach();
132}
133
134/// Waits for the thread to complete, then deallocates any resources created on `spawn()`.
135pub fn join(self: Thread) void {
136 return self.impl.join();
137}
138
139/// State to synchronize detachment of spawner thread to spawned thread
140const Completion = Atomic(enum {
141 running,
142 detached,
143 completed,
144});
145
123146/// Used by the Thread implementations to call the spawned function with the arguments.
124147fn callFn(comptime f: anytype, args: anytype) switch (Impl) {
125148 WindowsThreadImpl => windows.DWORD,
......@@ -172,29 +195,6 @@ fn callFn(comptime f: anytype, args: anytype) switch (Impl) {
172195 }
173196}
174197
175/// Retrns the handle of this thread
176/// On Linux and POSIX, this is the same as Id.
177pub fn getHandle(self: Thread) Handle {
178 return self.impl.getHandle();
179}
180
181/// Release the obligation of the caller to call `join()` and have the thread clean up its own resources on completion.
182pub fn detach(self: Thread) void {
183 return self.impl.detach();
184}
185
186/// Waits for the thread to complete, then deallocates any resources created on `spawn()`.
187pub fn join(self: Thread) void {
188 return self.impl.join();
189}
190
191/// State to synchronize detachment of spawner thread to spawned thread
192const Completion = Atomic(enum {
193 running,
194 detached,
195 completed,
196});
197
198198const WindowsThreadImpl = struct {
199199 const windows = os.windows;
200200