zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 14209cf615f2c218319e0c7a567484caf328dfe6 (tree)
parent 84e370d0b2ce2240356ebd0a6007aec8620dfa10
Author: kprotty <kbutcher6200@gmail.com>
Date:   Tue,  5 Nov 2019 13:43:17 -0600

make SpinLock.Backoff pub

Diffstat:
Mlib/std/spinlock.zig | 11++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git 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();