mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
std.Thread: don't spin
This commit is contained in:
parent
e4abdf5a13
commit
f97c91ddb5
1 changed files with 2 additions and 21 deletions
|
|
@ -911,18 +911,9 @@ const WasiThreadImpl = struct {
|
|||
allocator.free(self.thread.memory);
|
||||
}
|
||||
|
||||
var spin: u8 = 10;
|
||||
while (true) {
|
||||
const tid = self.thread.tid.load(.seq_cst);
|
||||
if (tid == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (spin > 0) {
|
||||
spin -= 1;
|
||||
std.atomic.spinLoopHint();
|
||||
continue;
|
||||
}
|
||||
if (tid == 0) break;
|
||||
|
||||
const result = asm (
|
||||
\\ local.get %[ptr]
|
||||
|
|
@ -1514,18 +1505,9 @@ const LinuxThreadImpl = struct {
|
|||
fn join(self: Impl) void {
|
||||
defer posix.munmap(self.thread.mapped);
|
||||
|
||||
var spin: u8 = 10;
|
||||
while (true) {
|
||||
const tid = self.thread.child_tid.load(.seq_cst);
|
||||
if (tid == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (spin > 0) {
|
||||
spin -= 1;
|
||||
std.atomic.spinLoopHint();
|
||||
continue;
|
||||
}
|
||||
if (tid == 0) break;
|
||||
|
||||
switch (linux.E.init(linux.futex_4arg(
|
||||
&self.thread.child_tid.raw,
|
||||
|
|
@ -1616,7 +1598,6 @@ test "setName, getName" {
|
|||
}
|
||||
|
||||
test {
|
||||
// Doesn't use testing.refAllDecls() since that would pull in the compileError spinLoopHint.
|
||||
_ = Futex;
|
||||
_ = ResetEvent;
|
||||
_ = Mutex;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue