Skip to main content

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__(out self)

Default constructor.

lock

lock(inout self, owner: Int)

Acquires the lock.

Args:

  • owner (Int): The lock's owner (usually an address).

unlock

unlock(inout self, owner: Int) -> Bool

Releases the lock.

Args:

  • owner (Int): The lock's owner (usually an address).

Returns:

The successful release of the lock.