# build runner: proper threaded dependency management · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/1fa1484288dc7431f73facb8c423b71670d6914e)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 1fa1484288dc7431f73facb8c423b71670d6914e

Requested commit: 1fa1484288dc7431f73facb8c423b71670d6914e

Commit: 1fa1484288dc7431f73facb8c423b71670d6914e

Tree: 22a09907edad86dc053a5c6fe49b7c57445772ed

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
build runner: proper threaded dependency management

After sorting the step stack so that dependencies can be popped before
their dependants are popped, there is still a situation left to handle
correctly:

Example:

A depends on:
  B
  C
D depends on:
  E
  F

They will be ordered like this:

A B C D E F

If there are 6+ cores, then all of them will be evaluated at once,
incorrectly evaluating A and D before their dependencies.

Starting evaluation of F and then E is correct, but waiting until they
are done is not correct because it should start working on B and C as
well.

This commit solves the problem by computing dependants in the dependency
loop checking logic, and then having workers queue up their dependants
when they finish their own work.

```

## Parents

- [cff86cf7a17e038db44fa1f72ee5919eea6a6cae](https://git.cafe/gitcafe/zig/commit/cff86cf7a17e038db44fa1f72ee5919eea6a6cae?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/1fa1484288dc7431f73facb8c423b71670d6914e?format=markdown)
