const UnsupportedImpl = struct fn getCurrentId() usizefn getCpuCount() !usizefn spawn(config: SpawnConfig, comptime f: anytype, args: anytype) !Implfn getHandle(self: Impl) ThreadHandlefn detach(self: Impl) voidfn join(self: Impl) voidfn unsupported(unused: anytype) noreturn464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495const UnsupportedImpl = struct {
pub const ThreadHandle = void;
fn getCurrentId() usize {
return unsupported({});
}
fn getCpuCount() !usize {
return unsupported({});
}
fn spawn(config: SpawnConfig, comptime f: anytype, args: anytype) !Impl {
return unsupported(.{ config, f, args });
}
fn getHandle(self: Impl) ThreadHandle {
return unsupported(self);
}
fn detach(self: Impl) void {
return unsupported(self);
}
fn join(self: Impl) void {
return unsupported(self);
}
fn unsupported(unused: anytype) noreturn {
_ = unused;
@compileError("Unsupported operating system " ++ @tagName(native_os));
}
}
We can't compile error in the
Implswitch statement as its eagerly evaluated. So instead, we compile-error on the methods themselves for platforms which don't support threads.