# rework std.ResetEvent, improve std lib Darwin integration · gitcafe/zig

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

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

Visibility: public

Requested revision: 177377b6e356b34bbed40cadca596658d158af6b

Requested commit: 177377b6e356b34bbed40cadca596658d158af6b

Commit: 177377b6e356b34bbed40cadca596658d158af6b

Tree: ed7e0a7fa146b8c15044e21f386ec8a8e2977695

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
rework std.ResetEvent, improve std lib Darwin integration

 * split std.ResetEvent into:
   - ResetEvent - requires init() at runtime and it can fail. Also
     requires deinit().
   - StaticResetEvent - can be statically initialized and requires no
     deinitialization. Initialization cannot fail.
 * the POSIX sem_t implementation can in fact fail on initialization
   because it is allowed to be implemented as a file descriptor.
 * Completely define, clarify, and explain in detail the semantics of
   these APIs. Remove the `isSet` function.
 * `ResetEvent.timedWait` returns an enum instead of a possible error.
 * `ResetEvent.init` takes a pointer to the ResetEvent instead of
   returning a copy.
 * On Darwin, `ResetEvent` is implemented using Grand Central Dispatch,
   which is exposed by libSystem.

stage2 changes:
 * ThreadPool: use a single, pre-initialized `ResetEvent` per worker.
 * WaitGroup: now requires init() and deinit() and init() can fail.
   - Add a `reset` function.
   - Compilation initializes one for the work queue in creation and
     re-uses it for every update.
   - Rename `stop` to `finish`.
   - Simplify the implementation based on the usage pattern.

```

## Parents

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

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