4 ms·
Isn’t there a race condition here? Thread 1 acquires the lock, but stalls before it writes the value. Thread 2 will not acquire the lock, but immediately attemp
by judofyr 4y ago
Isn’t there a race condition here? Thread 1 acquires the lock, but stalls before it writes the value. Thread 2 will not acquire the lock, but immediately attempt to read the value - which will be None and the unwrap will panic.
- maxbond 4y agoI concur. I imagine it's for compactness for the blog, but friends don't let friends call unwrap like that. Would've been better to return a Result.
- deleted 4y ago[deleted]