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"...@@ -25,6 +25,7 @@ pub const spinLoopHint = @compileError("deprecated: use std.atomic.spinLoopHint"
2525
26pub const use_pthreads = target.os.tag != .windows and std.builtin.link_libc;26pub const use_pthreads = target.os.tag != .windows and std.builtin.link_libc;
2727
28const Thread = @This();
28const Impl = if (target.os.tag == .windows)29const Impl = if (target.os.tag == .windows)
29 WindowsThreadImpl30 WindowsThreadImpl
30else if (use_pthreads)31else if (use_pthreads)
...@@ -36,7 +37,6 @@ else...@@ -36,7 +37,6 @@ else
3637
37impl: Impl,38impl: Impl,
3839
39
40/// Represents a kernel thread handle.40/// Represents a kernel thread handle.
41/// May be an integer or a pointer depending on the platform.41/// May be an integer or a pointer depending on the platform.
42/// On Linux and POSIX, this is the same as Id.42/// On Linux and POSIX, this is the same as Id.
...@@ -120,6 +120,29 @@ pub fn spawn(...@@ -120,6 +120,29 @@ pub fn spawn(
120 return .{ .impl = impl };120 return .{ .impl = impl };
121}121}
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
123/// Used by the Thread implementations to call the spawned function with the arguments.146/// Used by the Thread implementations to call the spawned function with the arguments.
124fn callFn(comptime f: anytype, args: anytype) switch (Impl) {147fn callFn(comptime f: anytype, args: anytype) switch (Impl) {
125 WindowsThreadImpl => windows.DWORD,148 WindowsThreadImpl => windows.DWORD,
...@@ -172,29 +195,6 @@ fn callFn(comptime f: anytype, args: anytype) switch (Impl) {...@@ -172,29 +195,6 @@ fn callFn(comptime f: anytype, args: anytype) switch (Impl) {
172 }195 }
173}196}
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
198const WindowsThreadImpl = struct {198const WindowsThreadImpl = struct {
199 const windows = os.windows;199 const windows = os.windows;
200200