Mojo struct
BlockingSpinLock
A basic locking implementation that uses an integer to represent the owner of the lock.
Aliasesβ
UNLOCKED = -1
: non-zero means locked, -1 means unlocked.
Fieldsβ
- βcounter (
Atomic[int64]
): The atomic counter implementing the spin lock.
Implemented traitsβ
AnyType
Methodsβ
__init__
β
__init__(inout self: Self)
Default constructor.
lock
β
lock(inout self: Self, owner: Int)
Acquires the lock.
Args:
- βowner (
Int
): The lock's owner (usually an address).
unlock
β
unlock(inout self: Self, owner: Int) -> Bool
Releases the lock.
Args:
- βowner (
Int
): The lock's owner (usually an address).
Returns:
The successful release of the lock.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!
If you'd like to share more information, please report an issue on GitHub
π What went wrong?