Harlequin RIP SDK
sync.c File Reference

Synchronization between the application calling thread and the thread that is running the RIP. Having this synchronization simplifies the application code because it doesn't need to worry about callbacks on the monitor or raster functions happening asynchronously - they will only happen when the application has called into one of the SwLe functions and is blocked waiting for the result. More...

#include "skinkit.h"
#include "sync.h"
#include "mem.h"
#include "ripthread.h"
#include "threadapi.h"
#include <locale.h>

Functions

static void * StartRipWrapper (void *unused)
 Wrapper to call StartRip() so we have the correct prototype for the thread starting 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

Synchronization between the application calling thread and the thread that is running the RIP. Having this synchronization simplifies the application code because it doesn't need to worry about callbacks on the monitor or raster functions happening asynchronously - they will only happen when the application has called into one of the SwLe functions and is blocked waiting for the result.

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.