Skip to main content
Log in

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?