# std.Thread.Mutex: change API to lock\(\) and unlock\(\) · gitcafe/zig

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

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

Visibility: public

Requested revision: 008b0ec5e58fc7e31f3b989868a7d1ea4df3f41d

Requested commit: 008b0ec5e58fc7e31f3b989868a7d1ea4df3f41d

Commit: 008b0ec5e58fc7e31f3b989868a7d1ea4df3f41d

Tree: 99374a7b0f5dc0bf56fc5daff702eecb7758d4f5

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

````
std.Thread.Mutex: change API to lock() and unlock()

This is a breaking change. Before, usage looked like this:

```zig
const held = mutex.acquire();
defer held.release();
```

Now it looks like this:

```zig
mutex.lock();
defer mutex.unlock();
```

The `Held` type was an idea to make mutexes slightly safer by making it
more difficult to forget to release an aquired lock. However, this
ultimately caused more problems than it solved, when any data structures
needed to store a held mutex. Simplify everything by reducing the API
down to the primitives: lock() and unlock().

Closes #8051
Closes #8246
Closes #10105

````

## Parents

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

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