commit 235fcc5ba632ced7e972e1c8b133418c17cd7ab7 (tree)
parent 3a276be1355fe304c177bcc13a7896122801e5f2
Author: kprotty <kbutcher6200@gmail.com>
Date: Sat, 19 Jun 2021 22:01:54 -0500
std.Thread: another typo fix
Diffstat:
1 file changed, 24 insertions(+), 24 deletions(-)
diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig
@@ -25,6 +25,7 @@ pub const spinLoopHint = @compileError("deprecated: use std.atomic.spinLoopHint"
pub const use_pthreads = target.os.tag != .windows and std.builtin.link_libc;
+const Thread = @This();
const Impl = if (target.os.tag == .windows)
WindowsThreadImpl
else if (use_pthreads)
@@ -36,7 +37,6 @@ else
impl: Impl,
-
/// Represents a kernel thread handle.
/// May be an integer or a pointer depending on the platform.
/// On Linux and POSIX, this is the same as Id.
@@ -120,6 +120,29 @@ pub fn spawn(
return .{ .impl = impl };
}
+/// Retrns the handle of this thread
+/// On Linux and POSIX, this is the same as Id.
+pub fn getHandle(self: Thread) Handle {
+ return self.impl.getHandle();
+}
+
+/// Release the obligation of the caller to call `join()` and have the thread clean up its own resources on completion.
+pub fn detach(self: Thread) void {
+ return self.impl.detach();
+}
+
+/// Waits for the thread to complete, then deallocates any resources created on `spawn()`.
+pub fn join(self: Thread) void {
+ return self.impl.join();
+}
+
+/// State to synchronize detachment of spawner thread to spawned thread
+const Completion = Atomic(enum {
+ running,
+ detached,
+ completed,
+});
+
/// Used by the Thread implementations to call the spawned function with the arguments.
fn callFn(comptime f: anytype, args: anytype) switch (Impl) {
WindowsThreadImpl => windows.DWORD,
@@ -172,29 +195,6 @@ fn callFn(comptime f: anytype, args: anytype) switch (Impl) {
}
}
-/// Retrns the handle of this thread
-/// On Linux and POSIX, this is the same as Id.
-pub fn getHandle(self: Thread) Handle {
- return self.impl.getHandle();
-}
-
-/// Release the obligation of the caller to call `join()` and have the thread clean up its own resources on completion.
-pub fn detach(self: Thread) void {
- return self.impl.detach();
-}
-
-/// Waits for the thread to complete, then deallocates any resources created on `spawn()`.
-pub fn join(self: Thread) void {
- return self.impl.join();
-}
-
-/// State to synchronize detachment of spawner thread to spawned thread
-const Completion = Atomic(enum {
- running,
- detached,
- completed,
-});
-
const WindowsThreadImpl = struct {
const windows = os.windows;