mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
make the main thread call waitAndWork instead of just wait
The main thread has an implicit thread token which makes loitering illegal.
This commit is contained in:
parent
dc207da184
commit
86e68dbf53
3 changed files with 15 additions and 20 deletions
|
|
@ -222,9 +222,6 @@ emit_asm: ?EmitLoc,
|
|||
emit_llvm_ir: ?EmitLoc,
|
||||
emit_llvm_bc: ?EmitLoc,
|
||||
|
||||
work_queue_wait_group: WaitGroup = .{},
|
||||
astgen_wait_group: WaitGroup = .{},
|
||||
|
||||
llvm_opt_bisect_limit: c_int,
|
||||
|
||||
pub const Emit = struct {
|
||||
|
|
@ -3251,13 +3248,13 @@ pub fn performAllTheWork(
|
|||
// (at least for now) single-threaded main work queue. However, C object compilation
|
||||
// only needs to be finished by the end of this function.
|
||||
|
||||
comp.work_queue_wait_group.reset();
|
||||
defer comp.work_queue_wait_group.wait();
|
||||
var work_queue_wait_group: WaitGroup = .{};
|
||||
defer comp.thread_pool.waitAndWork(&work_queue_wait_group);
|
||||
|
||||
if (!build_options.only_c and !build_options.only_core_functionality) {
|
||||
if (comp.docs_emit != null) {
|
||||
comp.thread_pool.spawnWg(&comp.work_queue_wait_group, workerDocsCopy, .{comp});
|
||||
comp.work_queue_wait_group.spawnManager(workerDocsWasm, .{ comp, main_progress_node });
|
||||
comp.thread_pool.spawnWg(&work_queue_wait_group, workerDocsCopy, .{comp});
|
||||
work_queue_wait_group.spawnManager(workerDocsWasm, .{ comp, main_progress_node });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3268,8 +3265,8 @@ pub fn performAllTheWork(
|
|||
const zir_prog_node = main_progress_node.start("AST Lowering", 0);
|
||||
defer zir_prog_node.end();
|
||||
|
||||
comp.astgen_wait_group.reset();
|
||||
defer comp.astgen_wait_group.wait();
|
||||
var astgen_wait_group: WaitGroup = .{};
|
||||
defer comp.thread_pool.waitAndWork(&astgen_wait_group);
|
||||
|
||||
// builtin.zig is handled specially for two reasons:
|
||||
// 1. to avoid race condition of zig processes truncating each other's builtin.zig files
|
||||
|
|
@ -3291,33 +3288,33 @@ pub fn performAllTheWork(
|
|||
|
||||
const file = mod.builtin_file orelse continue;
|
||||
|
||||
comp.thread_pool.spawnWg(&comp.astgen_wait_group, workerUpdateBuiltinZigFile, .{
|
||||
comp.thread_pool.spawnWg(&astgen_wait_group, workerUpdateBuiltinZigFile, .{
|
||||
comp, mod, file,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
while (comp.astgen_work_queue.readItem()) |file| {
|
||||
comp.thread_pool.spawnWg(&comp.astgen_wait_group, workerAstGenFile, .{
|
||||
comp, file, zir_prog_node, &comp.astgen_wait_group, .root,
|
||||
comp.thread_pool.spawnWg(&astgen_wait_group, workerAstGenFile, .{
|
||||
comp, file, zir_prog_node, &astgen_wait_group, .root,
|
||||
});
|
||||
}
|
||||
|
||||
while (comp.embed_file_work_queue.readItem()) |embed_file| {
|
||||
comp.thread_pool.spawnWg(&comp.astgen_wait_group, workerCheckEmbedFile, .{
|
||||
comp.thread_pool.spawnWg(&astgen_wait_group, workerCheckEmbedFile, .{
|
||||
comp, embed_file,
|
||||
});
|
||||
}
|
||||
|
||||
while (comp.c_object_work_queue.readItem()) |c_object| {
|
||||
comp.thread_pool.spawnWg(&comp.work_queue_wait_group, workerUpdateCObject, .{
|
||||
comp.thread_pool.spawnWg(&work_queue_wait_group, workerUpdateCObject, .{
|
||||
comp, c_object, main_progress_node,
|
||||
});
|
||||
}
|
||||
|
||||
if (!build_options.only_core_functionality) {
|
||||
while (comp.win32_resource_work_queue.readItem()) |win32_resource| {
|
||||
comp.thread_pool.spawnWg(&comp.work_queue_wait_group, workerUpdateWin32Resource, .{
|
||||
comp.thread_pool.spawnWg(&work_queue_wait_group, workerUpdateWin32Resource, .{
|
||||
comp, win32_resource, main_progress_node,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@ pub fn ParallelHasher(comptime Hasher: type) type {
|
|||
const tracy = trace(@src());
|
||||
defer tracy.end();
|
||||
|
||||
var wg: WaitGroup = .{};
|
||||
|
||||
const file_size = blk: {
|
||||
const file_size = opts.max_file_size orelse try file.getEndPos();
|
||||
break :blk std.math.cast(usize, file_size) orelse return error.Overflow;
|
||||
|
|
@ -27,8 +25,8 @@ pub fn ParallelHasher(comptime Hasher: type) type {
|
|||
defer self.allocator.free(results);
|
||||
|
||||
{
|
||||
wg.reset();
|
||||
defer wg.wait();
|
||||
var wg: WaitGroup = .{};
|
||||
defer self.thread_pool.waitAndWork(&wg);
|
||||
|
||||
for (out, results, 0..) |*out_buf, *result, i| {
|
||||
const fstart = i * chunk_size;
|
||||
|
|
|
|||
|
|
@ -5062,7 +5062,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
|
|||
job_queue.thread_pool.spawnWg(&job_queue.wait_group, Package.Fetch.workerRun, .{
|
||||
&fetch, "root",
|
||||
});
|
||||
job_queue.wait_group.wait();
|
||||
job_queue.thread_pool.waitAndWork(&job_queue.wait_group);
|
||||
|
||||
try job_queue.consolidateErrors();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue