Starboard Module Reference: mutex.h

Defines a mutually exclusive lock that can be used to coordinate with other threads.

Enums

SbMutexResult

Enumeration of possible results from acquiring a mutex.

Values

  • kSbMutexAcquired - The mutex was acquired successfully.
  • kSbMutexBusy - The mutex was not acquired because it was held by someone else.
  • kSbMutexDestroyed - The mutex has already been destroyed.

Functions

SbMutexAcquire

Description

Acquires mutex, blocking indefinitely. The return value identifies the acquisition result. SbMutexes are not reentrant, so a recursive acquisition blocks forever.

Declaration and definitions

SB_EXPORT SbMutexResult SbMutexAcquire(SbMutex* mutex);

#include "starboard/mutex.h"

SbMutexResult SbMutexAcquire(SbMutex* /*mutex*/) {
  return kSbMutexDestroyed;
}

Parameters

Parameters
SbMutex*
mutex
The mutex to be acquired.

SbMutexAcquireTry

Description

Acquires mutex, without blocking. The return value identifies the acquisition result. SbMutexes are not reentrant, so a recursive acquisition always fails.

Declaration and definitions

SB_EXPORT SbMutexResult SbMutexAcquireTry(SbMutex* mutex);

#include "starboard/mutex.h"

SbMutexResult SbMutexAcquireTry(SbMutex* /*mutex*/) {
  return kSbMutexDestroyed;
}

Parameters

Parameters
SbMutex*
mutex
The mutex to be acquired.

SbMutexCreate

Description

Creates a new mutex. The return value indicates whether the function was able to create a new mutex.

Declaration and definitions

SB_EXPORT bool SbMutexCreate(SbMutex* out_mutex);

#include "starboard/mutex.h"

bool SbMutexCreate(SbMutex* /*mutex*/) {
  return false;
}

Parameters

Parameters
SbMutex*
out_mutex
The handle to the newly created mutex.

SbMutexDestroy

Description

Destroys a mutex. The return value indicates whether the destruction was successful.

Declaration and definitions

SB_EXPORT bool SbMutexDestroy(SbMutex* mutex);

#include "starboard/mutex.h"

bool SbMutexDestroy(SbMutex* /*mutex*/) {
  return false;
}

Parameters

Parameters
SbMutex*
mutex
The mutex to be invalidated.

SbMutexIsSuccess

Description

Indicates whether the given result is a success. A value of true indicates that the mutex was acquired.

Declaration

static SB_C_FORCE_INLINE bool SbMutexIsSuccess(SbMutexResult result) {
  return result == kSbMutexAcquired;
}

Parameters

Parameters
SbMutexResult
result
The result being checked.

SbMutexRelease

Description

Releases mutex held by the current thread. The return value indicates whether the release was successful. Releases should always be successful if mutex is held by the current thread.

Declaration and definitions

SB_EXPORT bool SbMutexRelease(SbMutex* mutex);

#include "starboard/mutex.h"

bool SbMutexRelease(SbMutex* /*mutex*/) {
  return false;
}

Parameters

Parameters
SbMutex*
mutex
The mutex to be released.