You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constMutex=@import("std").Thread.Mutex;
varmutex=Mutex{};
constheld: Mutex.Held=mutex.acquire(); // Mutex.Held is missing
This seems to have been forgotten in 9698ea3. I tried to add it myself (#8245) but it causes shadowing errors so either the implementations would have to be moved to a separate file or shadowing rules have to be changed (the current shadow rules will also cause Mutex.zig to no longer compile after functions are made into expressions because tryAcquire and acquire shadow the implementations)
The text was updated successfully, but these errors were encountered:
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().
Closesziglang#8051Closesziglang#8246Closesziglang#10105
This seems to have been forgotten in 9698ea3. I tried to add it myself (#8245) but it causes shadowing errors so either the implementations would have to be moved to a separate file or shadowing rules have to be changed (the current shadow rules will also cause Mutex.zig to no longer compile after functions are made into expressions because tryAcquire and acquire shadow the implementations)
The text was updated successfully, but these errors were encountered: