Address waits v0.1.0

Source
Waiting on a word and waking its waiters through ulock_wait and ulock_wake.

Waiting on a word and waking its waiters through __ulock_wait and __ulock_wake.

UL_COMPARE_AND_WAIT

pub const UL_COMPARE_AND_WAIT: uint32 = 1;

UL_COMPARE_AND_WAIT: wait on a 32-bit word that holds the expected value.

Source

ULF_WAKE_ALL

pub const ULF_WAKE_ALL: uint32 = 0x100;

ULF_WAKE_ALL: wake every thread waiting on the word rather than one.

Source

ULF_NO_ERRNO

pub const ULF_NO_ERRNO: uint32 = 0x01000000;

ULF_NO_ERRNO: report failure as a negative error number rather than through errno.

Source

__ulock_wait

pub extern func __ulock_wait(
    operation: uint32,
    address: *opaque,
    value: uint64,
    timeout: uint32
) -> int32

Sleeps while *address equals value, until a wake, a signal or the timeout.

Source

Parameters

NameTypeDescription
operationuint32UL_COMPARE_AND_WAIT, combined with ULF_NO_ERRNO
address*opaquethe word to wait on, four-byte aligned
valueuint64the value the caller last saw there
timeoutuint32microseconds to wait at most, or zero to wait without a limit

Returns: the number of waiters left, or a failure: EINTR, ETIMEDOUT, or EFAULT when the word moved

__ulock_wake

pub extern func __ulock_wake(
    operation: uint32,
    address: *opaque,
    wakeValue: uint64
) -> int32

Wakes a thread, or all of them with ULF_WAKE_ALL, sleeping on address.

Source

Parameters

NameTypeDescription
operationuint32UL_COMPARE_AND_WAIT, combined with ULF_WAKE_ALL and ULF_NO_ERRNO
address*opaquethe word they wait on
wakeValueuint64zero

Returns: zero, or a failure: ENOENT when nothing was waiting