mirror of
https://github.com/ziglang/zig.git
synced 2025-12-17 19:53:06 +00:00
std: add option to use single-threaded event loop
std.event.Loop does not yet work in single threaded builds. However,
using evented io on a single thread can be very convenient. This commit
allows settind @import("root").event_loop_mode to .single_threaded
in order to allow this without reimplementing the startup code in
start.zig
This commit is contained in:
parent
4170f3f77f
commit
486a774e5f
@ -112,7 +112,8 @@ pub const Loop = struct {
|
|||||||
/// have the correct pointer value.
|
/// have the correct pointer value.
|
||||||
/// https://github.com/ziglang/zig/issues/2761 and https://github.com/ziglang/zig/issues/2765
|
/// https://github.com/ziglang/zig/issues/2761 and https://github.com/ziglang/zig/issues/2765
|
||||||
pub fn init(self: *Loop) !void {
|
pub fn init(self: *Loop) !void {
|
||||||
if (builtin.single_threaded) {
|
if (builtin.single_threaded
|
||||||
|
or (@hasDecl(root, "event_loop_mode") and root.event_loop_mode == .single_threaded)) {
|
||||||
return self.initSingleThreaded();
|
return self.initSingleThreaded();
|
||||||
} else {
|
} else {
|
||||||
return self.initMultiThreaded();
|
return self.initMultiThreaded();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user