Warning
This post was published 57 days ago. The information described in this article may have changed.
Hello everyone!
Recently, I've looking the standard library synchronization primitives (Mutex
and RwLock
), and found that there are only "blocking lock" and "try to lock" (fails immediately for contention) methods, but no way to set a timeout. Is there any reason why there aren't such methods (maybe, not all platform support it)? As an alternative, I'm looking at the parking_lot
crate, which does provide locking attempt with time-out on contention (however, I'm confused that their mutex only takes one byte of space -- however, the futex()
syscall on Linux takes a pointer to the four-byte "futex word" -- how do they manage to take less space?).
2 posts - 2 participants
🏷️ rust_feed