mirror of
https://github.com/Noratrieb/nuclear.git
synced 2026-01-16 08:45: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
|
// don't use spin loops
|
||||||
// but I can't be bothered with the proper solution
|
// but I can't be bothered with the proper solution
|
||||||
loop {
|
loop {
|
||||||
if self
|
if self.status.compare_exchange_weak(
|
||||||
.status
|
INIT,
|
||||||
.compare_exchange(INIT, ACQUIRED, Ordering::Acquire, Ordering::Relaxed)
|
ACQUIRED,
|
||||||
{
|
Ordering::Acquire,
|
||||||
|
Ordering::Relaxed,
|
||||||
|
) {
|
||||||
return MutexGuard { mutex: self };
|
return MutexGuard { mutex: self };
|
||||||
} else {
|
} else {
|
||||||
std::hint::spin_loop();
|
std::hint::spin_loop();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue