aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.zig
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2025-08-05 22:48:50 +0100
committerMatthew Lugg <mlugg@mlugg.co.uk>2025-08-06 21:50:16 +0100
commite17a050bc695f7d117b89adb1d258813593ca111 (patch)
treef281876485848c783fb9e2a10616b98cda0b2e09 /src/codegen.zig
parent3de8bbd3d4e262df11a582fb52401b8077b5f352 (diff)
downloadzig-e17a050bc695f7d117b89adb1d258813593ca111.tar.gz
zig-e17a050bc695f7d117b89adb1d258813593ca111.zip
link: prevent deadlock when prelink tasks fail
If an error occured which prevented a prelink task from being queued, then `pending_prelink_tasks` would never be decremented, which could cause deadlocks in some cases. So, instead of calculating ahead of time the number of prelink tasks to expect, we use a simpler strategy which is much like a wait group: we add 1 to a value when we spawn a worker, and in the worker function, `defer` decrementing the value. The initial value is 1, and there's a decrement after all of the workers are spawned, so once it hits 0, prelink is done (be it with a failure or a success).
Diffstat (limited to 'src/codegen.zig')
0 files changed, 0 insertions, 0 deletions