updateThreadRun
Type definitions in this namespace
Types
- Node
- Represents one unit of progress.
Initializes a global Progress instance.
Functions
- start
- Initializes a global Progress instance.
- lockStdErr
- Allows the caller to freely write to stderr until `unlockStdErr` is called.
- lockStderrWriter
- Allows the caller to freely write to the returned `Writer`,
= switch (builtin.os.tag) { .wasi, .freestanding, .windows => false, else => true, }
Values
- have_ipc
- = switch (builtin.os.tag) { .wasi, .freestanding, .windows => false, else => true, }
Source
Implementation
fn updateThreadRun() void {
// Store this data in the thread so that it does not need to be part of the
// linker data of the main executable.
var serialized_buffer: Serialized.Buffer = undefined;
{
const resize_flag = wait(global_progress.initial_delay_ns);
if (@atomicLoad(bool, &global_progress.done, .monotonic)) return;
maybeUpdateSize(resize_flag);
const buffer, _ = computeRedraw(&serialized_buffer);
if (stderr_mutex.tryLock()) {
defer stderr_mutex.unlock();
write(buffer) catch return;
global_progress.need_clear = true;
}
}
while (true) {
const resize_flag = wait(global_progress.refresh_rate_ns);
if (@atomicLoad(bool, &global_progress.done, .monotonic)) {
stderr_mutex.lock();
defer stderr_mutex.unlock();
return clearWrittenWithEscapeCodes() catch {};
}
maybeUpdateSize(resize_flag);
const buffer, _ = computeRedraw(&serialized_buffer);
if (stderr_mutex.tryLock()) {
defer stderr_mutex.unlock();
write(buffer) catch return;
global_progress.need_clear = true;
}
}
}