diff --git a/lib/std/spinlock.zig b/lib/std/spinlock.zig index 8a485ef0fe64e85b0e4f09c48fef90672f5243ec..c45778cec1f7d41253e3a75af858d76c9939a43d 100644 --- a/lib/std/spinlock.zig +++ b/lib/std/spinlock.zig @@ -44,16 +44,17 @@ pub const SpinLock = struct { } } - const Backoff = struct { + /// Provides a method to incrementally yield longer each time its called. + pub const Backoff = struct { iteration: usize, - fn init() @This() { + pub fn init() @This() { return @This(){ .iteration = 0 }; } - // Hybrid yielding from - // http://www.1024cores.net/home/lock-free-algorithms/tricks/spinning - fn yield(self: *@This()) void { + /// Hybrid yielding from + /// http://www.1024cores.net/home/lock-free-algorithms/tricks/spinning + pub fn yield(self: *@This()) void { defer self.iteration +%= 1; if (self.iteration < 10) { yieldCpu();