mirror of
https://github.com/ziglang/zig.git
synced 2024-11-30 09:02:32 +00:00
std: avoid referencing event loop when io_mode is blocking
This prevents unwanted symbols from ending up in the output binary.
This commit is contained in:
parent
9821a0c6f0
commit
83617eac59
@ -103,12 +103,17 @@ pub const Loop = struct {
|
||||
};
|
||||
};
|
||||
|
||||
var global_instance_state: Loop = undefined;
|
||||
const default_instance: ?*Loop = switch (std.io.mode) {
|
||||
const LoopOrVoid = switch (std.io.mode) {
|
||||
.blocking => void,
|
||||
.evented => Loop,
|
||||
};
|
||||
|
||||
var global_instance_state: LoopOrVoid = undefined;
|
||||
const default_instance: ?*LoopOrVoid = switch (std.io.mode) {
|
||||
.blocking => null,
|
||||
.evented => &global_instance_state,
|
||||
};
|
||||
pub const instance: ?*Loop = if (@hasDecl(root, "event_loop")) root.event_loop else default_instance;
|
||||
pub const instance: ?*LoopOrVoid = if (@hasDecl(root, "event_loop")) root.event_loop else default_instance;
|
||||
|
||||
/// TODO copy elision / named return values so that the threads referencing *Loop
|
||||
/// have the correct pointer value.
|
||||
|
Loading…
Reference in New Issue
Block a user