Synchronisation and timing

EsEventCreate

EsHandle EsEventCreate(bool autoReset);

Creates an event. Returns a handle, or ES_INVALID_HANDLE on failure. Close with EsHandleClose.

EsEventReset

void EsEventReset(EsHandle event);

Sets the event to the non-signalled state.

EsEventSet

void EsEventSet(EsHandle event);

Signals the event, waking up waiting threads.

EsMutexAcquire

void EsMutexAcquire(EsMutex *mutex);

Locks the mutex. Blocks until the mutex is free.

EsMutexDestroy

void EsMutexDestroy(EsMutex *mutex);

Frees the resources of an unlocked mutex.

EsMutexRelease

void EsMutexRelease(EsMutex *mutex);

Unlocks the mutex. Panics if it is not locked.

EsSchedulerYield

void EsSchedulerYield();

Gives up the rest of the current time slice.

EsSpinlockAcquire

void EsSpinlockAcquire(EsSpinlock *spinlock);

Locks a spinlock, busy-waiting until it is free.

EsSpinlockRelease

void EsSpinlockRelease(EsSpinlock *spinlock);

Unlocks a spinlock. Panics if it is not locked.

EsTimerSet

EsTimer EsTimerSet(uint64_t afterMs, EsTimerCallback callback, EsGeneric argument);

Runs the callback after the given number of milliseconds. Returns a timer ID, or 0 on failure. Cancel with EsTimerCancel.

EsTimerCancel

void EsTimerCancel(EsTimer id);

Cancels a timer created with EsTimerSet.

EsSleep

void EsSleep(uint64_t milliseconds);

Blocks the calling thread for the given number of milliseconds.

EsWait

uintptr_t EsWait(const EsHandle *objects, size_t objectCount, uintptr_t timeoutMs);

Blocks until one of the objects is signalled or the timeout expires. Objects can be events, processes, or threads. Returns the index of the signalled object, or ES_ERROR_TIMEOUT_REACHED on timeout.

EsTimeStampMs

double EsTimeStampMs();

Current value of the performance timer, in ms.

EsDateNowUTC

void EsDateNowUTC(EsDateComponents *date);

Don't rely on the accuracy of the millisecond field.