mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-27 19:09:47 +03:00
std.Io: add ResetEvent based on futexes
and add futex to the vtable. A future commit may make the other sync primitives based on futexes.
This commit is contained in:
@@ -52,14 +52,14 @@ pub const Mode = union(enum) {
|
||||
return switch (m) {
|
||||
.positional, .positional_simple => .positional_simple,
|
||||
.streaming, .streaming_simple => .streaming_simple,
|
||||
inline else => |x| x,
|
||||
inline else => |_, x| x,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn toUnescaped(m: @This()) @This() {
|
||||
return switch (m) {
|
||||
.terminal_escaped => .streaming_simple,
|
||||
inline else => |x| x,
|
||||
inline else => |_, x| x,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -469,13 +469,13 @@ pub fn restoreEscape(w: *Writer, mode: Mode) void {
|
||||
w.mode = mode;
|
||||
}
|
||||
|
||||
pub fn writeAllUnescaped(w: *Writer, bytes: []const u8) Io.Error!void {
|
||||
pub fn writeAllUnescaped(w: *Writer, bytes: []const u8) Io.Writer.Error!void {
|
||||
const prev_mode = w.disableEscape();
|
||||
defer w.restoreEscape(prev_mode);
|
||||
return w.interface.writeAll(bytes);
|
||||
}
|
||||
|
||||
pub fn printUnescaped(w: *Writer, comptime fmt: []const u8, args: anytype) Io.Error!void {
|
||||
pub fn printUnescaped(w: *Writer, comptime fmt: []const u8, args: anytype) Io.Writer.Error!void {
|
||||
const prev_mode = w.disableEscape();
|
||||
defer w.restoreEscape(prev_mode);
|
||||
return w.interface.print(fmt, args);
|
||||
|
||||
@@ -52,6 +52,8 @@ node_freelist: Freelist,
|
||||
/// value may at times temporarily exceed the node count.
|
||||
node_end_index: u32,
|
||||
|
||||
start_failure: StartFailure,
|
||||
|
||||
pub const Status = enum {
|
||||
/// Indicates the application is progressing towards completion of a task.
|
||||
/// Unless the application is interactive, this is the only status the
|
||||
@@ -448,6 +450,8 @@ const noop_impl = builtin.single_threaded or switch (builtin.os.tag) {
|
||||
/// Asserts there is only one global Progress instance.
|
||||
///
|
||||
/// Call `Node.end` when done.
|
||||
///
|
||||
/// If an error occurs, `start_failure` will be populated.
|
||||
pub fn start(options: Options, io: Io) Node {
|
||||
// Ensure there is only 1 global Progress object.
|
||||
if (global_progress.node_end_index != 0) {
|
||||
@@ -757,7 +761,7 @@ fn appendTreeSymbol(symbol: TreeSymbol, buf: []u8, start_i: usize) usize {
|
||||
|
||||
pub fn clearWrittenWithEscapeCodes(file_writer: *Io.File.Writer) anyerror!void {
|
||||
if (noop_impl or !global_progress.need_clear) return;
|
||||
try file_writer.interface.writeAllUnescaped(clear ++ progress_remove);
|
||||
try file_writer.writeAllUnescaped(clear ++ progress_remove);
|
||||
global_progress.need_clear = false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user