# std.Thread.Pool: implement jobserverv2 protocol · gitcafe/zig

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

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

Visibility: public

Requested revision: c395df25aba0f1bdc1dd0cb6b9c7f14a90e72dae

Requested commit: c395df25aba0f1bdc1dd0cb6b9c7f14a90e72dae

Commit: c395df25aba0f1bdc1dd0cb6b9c7f14a90e72dae

Tree: c79aa15fa1460b29b92986713991ab7242c38c38

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
std.Thread.Pool: implement jobserverv2 protocol

The host accepts N simultaneous connections and writes 1 byte to them
each. Clients connect and read 1 byte in order to obtain a thread token.

std.Thread.Pool now lazily spawns threads only when the work queue is
non-empty. I think that was a bad idea and will revert it shortly.

There is now a std.zig.initThreadPool wrapper that deals with:
* Resolving a zig cache directory into a UNIX domain socket address.
* Creating the "tmp" directory in .zig-cache but only if the listen
  failed due to ENOENT.
* Deciding to connect to an existing jobserver, or become the host for
  child processes.

```

## Parents

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

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