ARX  1.2.0
The next-generation open source augmented reality toolkit.
Loading...
Searching...
No Matches
thread_sub.h File Reference
#include <ARX/ARUtil/types.h>
Include dependency graph for thread_sub.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef struct _THREAD_HANDLE_T THREAD_HANDLE_T

Functions

ARUTIL_EXTERN THREAD_HANDLE_T * threadInit (int ID, void *arg, void *(*start_routine)(THREAD_HANDLE_T *))
 Client-side, set up.
ARUTIL_EXTERN int threadFree (THREAD_HANDLE_T **flag)
 Client-side, set up. Frees structures associated with the thread handle pointed to by the location pointed to by flag. Thread should already have terminated (i.e. threadWaitQuit() has returned). Location pointed to by flag is set to NULL.
ARUTIL_EXTERN int threadStartSignal (THREAD_HANDLE_T *flag)
 Client-side, communication. Send the worker thread the "start processing" request.
ARUTIL_EXTERN int threadGetStatus (THREAD_HANDLE_T *flag)
 Client-side, communication. Find out (without waiting) whether a worker has ended. 0 = not started or started but not yet ended, 1 = ended.
ARUTIL_EXTERN int threadGetBusyStatus (THREAD_HANDLE_T *flag)
 Client-side, communication. Find out if a worker is currently busy. 0 = worker not started or worker ended, 1 = worker started but not yet ended.
ARUTIL_EXTERN int threadEndWait (THREAD_HANDLE_T *flag)
 Client-side, communication. Wait for thread to end processing.
ARUTIL_EXTERN int threadWaitQuit (THREAD_HANDLE_T *flag)
 Client-side, communication. Tell a thread waiting for the "start processing" request to quit (exit), and wait until this has happened.
ARUTIL_EXTERN int threadStartWait (THREAD_HANDLE_T *flag)
 Worker-side.
ARUTIL_EXTERN int threadEndSignal (THREAD_HANDLE_T *flag)
 Worker-side. Notify anyone waiting that the worker has ended.
ARUTIL_EXTERN int threadGetID (THREAD_HANDLE_T *flag)
 Worker-side. Get the 'ID' value passed to the thread's start routine.
ARUTIL_EXTERN void * threadGetArg (THREAD_HANDLE_T *flag)
 Worker-side. Get the 'arg' value passed to the thread's start routine.
ARUTIL_EXTERN int threadGetCPU (void)
 Returns the number of online CPUs in the system.

Typedef Documentation

◆ THREAD_HANDLE_T

Function Documentation

◆ threadEndSignal()

ARUTIL_EXTERN int threadEndSignal ( THREAD_HANDLE_T * flag)

Worker-side. Notify anyone waiting that the worker has ended.

Here is the call graph for this function:

◆ threadEndWait()

ARUTIL_EXTERN int threadEndWait ( THREAD_HANDLE_T * flag)

Client-side, communication. Wait for thread to end processing.

Here is the call graph for this function:

◆ threadFree()

ARUTIL_EXTERN int threadFree ( THREAD_HANDLE_T ** flag)

Client-side, set up. Frees structures associated with the thread handle pointed to by the location pointed to by flag. Thread should already have terminated (i.e. threadWaitQuit() has returned). Location pointed to by flag is set to NULL.

Here is the call graph for this function:

◆ threadGetArg()

ARUTIL_EXTERN void * threadGetArg ( THREAD_HANDLE_T * flag)

Worker-side. Get the 'arg' value passed to the thread's start routine.

Here is the call graph for this function:

◆ threadGetBusyStatus()

ARUTIL_EXTERN int threadGetBusyStatus ( THREAD_HANDLE_T * flag)

Client-side, communication. Find out if a worker is currently busy. 0 = worker not started or worker ended, 1 = worker started but not yet ended.

Here is the call graph for this function:

◆ threadGetCPU()

ARUTIL_EXTERN int threadGetCPU ( void )

Returns the number of online CPUs in the system.

Here is the call graph for this function:

◆ threadGetID()

ARUTIL_EXTERN int threadGetID ( THREAD_HANDLE_T * flag)

Worker-side. Get the 'ID' value passed to the thread's start routine.

Here is the call graph for this function:

◆ threadGetStatus()

ARUTIL_EXTERN int threadGetStatus ( THREAD_HANDLE_T * flag)

Client-side, communication. Find out (without waiting) whether a worker has ended. 0 = not started or started but not yet ended, 1 = ended.

Here is the call graph for this function:

◆ threadInit()

ARUTIL_EXTERN THREAD_HANDLE_T * threadInit ( int ID,
void * arg,
void * start_routine (*)(THREAD_HANDLE_T *) )

Client-side, set up.

Create a new thread, and launch start_routine() on it. Returns NULL in case of failure.

Example client structure:

THREAD_HANDLE_T *threadHandle = threadInit(0, NULL, worker);
if (!threadHandle) {
fprintf(stderr, "Error starting thread.\n");
exit(-1);
}
// Ready to do some work:
threadStartSignal(threadHandle);
// Wait for the results.
threadEndWait(threadHandle);
// If all done, quit and cleanup.
threadWaitQuit(threadHandle);
threadFree(&threadHandle);
ARUTIL_EXTERN int threadWaitQuit(THREAD_HANDLE_T *flag)
Client-side, communication. Tell a thread waiting for the "start processing" request to quit (exit),...
Definition thread_sub.c:247
ARUTIL_EXTERN int threadEndWait(THREAD_HANDLE_T *flag)
Client-side, communication. Wait for thread to end processing.
Definition thread_sub.c:236
struct _THREAD_HANDLE_T THREAD_HANDLE_T
Definition thread_sub.h:56
ARUTIL_EXTERN THREAD_HANDLE_T * threadInit(int ID, void *arg, void *(*start_routine)(THREAD_HANDLE_T *))
Client-side, set up.
Definition thread_sub.c:152
ARUTIL_EXTERN int threadFree(THREAD_HANDLE_T **flag)
Client-side, set up. Frees structures associated with the thread handle pointed to by the location po...
Definition thread_sub.c:197
ARUTIL_EXTERN int threadStartSignal(THREAD_HANDLE_T *flag)
Client-side, communication. Send the worker thread the "start processing" request.
Definition thread_sub.c:207
Here is the call graph for this function:

◆ threadStartSignal()

ARUTIL_EXTERN int threadStartSignal ( THREAD_HANDLE_T * flag)

Client-side, communication. Send the worker thread the "start processing" request.

Here is the call graph for this function:

◆ threadStartWait()

ARUTIL_EXTERN int threadStartWait ( THREAD_HANDLE_T * flag)

Worker-side.

Wait for the "start processing" request. Returns 0 if worker should start, or -1 if worker should quit (exit).

Example worker structure:

void *worker(THREAD_HANDLE_T *threadHandle)
{
void *arg = threadHandle->arg; // Get data passed to the worker.
while (threadStartWait(threadHandle) == 0) {
// Do work, probably on arg.
threadEndSignal(threadHandle);
}
// Do cleanup.
return (NULL);
}
void * arg
Definition thread_sub.c:87
ARUTIL_EXTERN int threadStartWait(THREAD_HANDLE_T *flag)
Worker-side.
Definition thread_sub.c:94
ARUTIL_EXTERN int threadEndSignal(THREAD_HANDLE_T *flag)
Worker-side. Notify anyone waiting that the worker has ended.
Definition thread_sub.c:114
Here is the call graph for this function:

◆ threadWaitQuit()

ARUTIL_EXTERN int threadWaitQuit ( THREAD_HANDLE_T * flag)

Client-side, communication. Tell a thread waiting for the "start processing" request to quit (exit), and wait until this has happened.

Here is the call graph for this function: