Harlequin RIP SDK
sync.h File Reference

Cross platform synchronization primitives. More...

#include "std.h"
#include "swoften.h"

Functions

HqBool StartRIPOnNewThread (void)
 Create a thread and then call the function StartRip() to start a Harlequin Core RIP on it. More...
 
void WaitForRIPThreadToExit (void)
 Wait for the RIP thread to exit.
 
void * PKCreateSemaphore (int32 initialValue)
 Create a semaphore with an initial value. More...
 
HqBool PKSignalSemaphore (void *semaHandle)
 Increment the value of a semaphore. More...
 
HqBool PKWaitOnSemaphore (void *semaHandle)
 Wait on a semaphore. More...
 
void PKDestroySemaphore (void *semaHandle)
 Free up the resources associated with the semaphore. More...
 
void PKSemaFinish (void)
 Finish semaphore module, free up resources for remaining semaphores.
 

Detailed Description

Cross platform synchronization primitives.

Function Documentation

◆ PKCreateSemaphore()

void* PKCreateSemaphore ( int32  initialValue)

Create a semaphore with an initial value.

Parameters
initialValueInitial value of the semaphore.
Returns
NULL if this failed, otherwise a platform-dependent handle to the semaphore.

◆ PKDestroySemaphore()

void PKDestroySemaphore ( void *  semaHandle)

Free up the resources associated with the semaphore.

Parameters
semaHandlePlatform-specific handle to a semaphore created by PKCreateSemaphore().

◆ PKSignalSemaphore()

HqBool PKSignalSemaphore ( void *  semaHandle)

Increment the value of a semaphore.

Parameters
semaHandlePlatform-specific handle to a semaphore created by PKCreateSemaphore().

If any threads are blocked in PKWaitOnSemaphore(), then wake them up.

Return values
TRUEIf the semaphore was incremented successfully;
FALSEotherwise.

◆ PKWaitOnSemaphore()

HqBool PKWaitOnSemaphore ( void *  semaHandle)

Wait on a semaphore.

Parameters
semaHandlePlatform-specific handle to a semaphore created by PKCreateSemaphore().

If the semaphore value is > 0 then decrement it and carry on. If it's already 0 then block until it is signalled with PKSignalSemaphore(), then decrement it and return.

Return values
TRUEIf the semaphore was decremented successfully;
FALSEotherwise.

◆ StartRIPOnNewThread()

HqBool StartRIPOnNewThread ( void  )

Create a thread and then call the function StartRip() to start a Harlequin Core RIP on it.

Return values
TRUEif the thread was created successfully;
FALSEif the thread was not created successfully.