mirror of
https://github.com/Noratrieb/nuclear.git
synced 2026-01-14 15:55:02 +01:00
weak af
This commit is contained in:
parent
972c8f6970
commit
1a76116ed0
1 changed files with 6 additions and 4 deletions
10
src/mutex.rs
10
src/mutex.rs
|
|
@ -34,10 +34,12 @@ impl<T> Mutex<T> {
|
|||
// don't use spin loops
|
||||
// but I can't be bothered with the proper solution
|
||||
loop {
|
||||
if self
|
||||
.status
|
||||
.compare_exchange(INIT, ACQUIRED, Ordering::Acquire, Ordering::Relaxed)
|
||||
{
|
||||
if self.status.compare_exchange_weak(
|
||||
INIT,
|
||||
ACQUIRED,
|
||||
Ordering::Acquire,
|
||||
Ordering::Relaxed,
|
||||
) {
|
||||
return MutexGuard { mutex: self };
|
||||
} else {
|
||||
std::hint::spin_loop();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue