mUPnP for C
thread.c File Reference
#include <string.h>
#include <signal.h>
#include <mupnp/util/log.h>
#include <mupnp/util/thread.h>
#include <mupnp/util/time.h>

Functions

static void sig_handler (int sign)
 
static void mupnp_thread_createkey ()
 
mUpnpThreadmupnp_thread_self ()
 
static void * PosixThreadProc (void *param)
 
mUpnpThreadmupnp_thread_new ()
 
bool mupnp_thread_delete (mUpnpThread *thread)
 
bool mupnp_thread_start (mUpnpThread *thread)
 
bool mupnp_thread_stop (mUpnpThread *thread)
 
bool mupnp_thread_stop_with_cond (mUpnpThread *thread, mUpnpCond *cond)
 
bool mupnp_thread_restart (mUpnpThread *thread)
 
bool mupnp_thread_isrunnable (mUpnpThread *thread)
 
void mupnp_thread_setaction (mUpnpThread *thread, MUPNP_THREAD_FUNC func)
 
void mupnp_thread_setuserdata (mUpnpThread *thread, void *value)
 
void * mupnp_thread_getuserdata (mUpnpThread *thread)
 

Variables

static pthread_key_t mupnp_thread_self_ref
 
static pthread_once_t mupnp_thread_mykeycreated = PTHREAD_ONCE_INIT
 

Function Documentation

◆ mupnp_thread_createkey()

static void mupnp_thread_createkey ( )
static

◆ mupnp_thread_delete()

bool mupnp_thread_delete ( mUpnpThread * thread)

Stop and destroy a thread.

Parameters
threadThread to destroy

◆ mupnp_thread_getuserdata()

void * mupnp_thread_getuserdata ( mUpnpThread * thread)

Get the user data pointer

Parameters
threadThread from which to get the pointer

◆ mupnp_thread_isrunnable()

bool mupnp_thread_isrunnable ( mUpnpThread * thread)

Check if a thread has been started

Parameters
threadThread to check

◆ mupnp_thread_new()

mUpnpThread * mupnp_thread_new ( void )

Create a new thread

◆ mupnp_thread_restart()

bool mupnp_thread_restart ( mUpnpThread * thread)

Restart a thread. Essentially calls mupnp_thread_stop() and mupnp_thread_start()

Parameters
threadThread to restart

◆ mupnp_thread_self()

mUpnpThread * mupnp_thread_self ( void )

Get a self reference to thread.

◆ mupnp_thread_setaction()

void mupnp_thread_setaction ( mUpnpThread * thread,
MUPNP_THREAD_FUNC actionFunc )

Set the thread's worker function.

Parameters
threadThread struct
actionFuncFunction pointer to set as the worker function

◆ mupnp_thread_setuserdata()

void mupnp_thread_setuserdata ( mUpnpThread * thread,
void * data )

Set the user data pointer

Parameters
threadThread struct
dataPointer to user data

◆ mupnp_thread_start()

bool mupnp_thread_start ( mUpnpThread * thread)

Start a thread (must be created first with ch_thread_new())

Parameters
threadThread to start

◆ mupnp_thread_stop()

bool mupnp_thread_stop ( mUpnpThread * thread)

Stop a running thread.

Parameters
threadThread to stop

◆ mupnp_thread_stop_with_cond()

bool mupnp_thread_stop_with_cond ( mUpnpThread * thread,
mUpnpCond * cond )

Stop the running thread and signal the given CGCond.

◆ PosixThreadProc()

static void * PosixThreadProc ( void * param)
static

◆ sig_handler()

static void sig_handler ( int sign)
static

Variable Documentation

◆ mupnp_thread_mykeycreated

pthread_once_t mupnp_thread_mykeycreated = PTHREAD_ONCE_INIT
static

◆ mupnp_thread_self_ref

pthread_key_t mupnp_thread_self_ref
static