thread.h
Go to the documentation of this file.
#ifndef _VN_THREAD_H_
#define _VN_THREAD_H_
#include "vn/error.h"
#include "vn/int.h"
#ifdef _WIN32
/* Disable some warnings for Visual Studio with -Wall. */
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4668)
#pragma warning(disable:4820)
#pragma warning(disable:4255)
#endif
#include <Windows.h>
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
#endif
#if defined __linux__ || defined __APPLE__ || defined __CYGWIN__ || defined __QNXNTO__
#include <pthread.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef struct
{
#ifdef _WIN32
HANDLE handle;
#elif defined __linux__ || defined __APPLE__ || defined __CYGWIN__ || defined __QNXNTO__
pthread_t handle;
#else
#error "Unknown System"
#endif
} VnThread;
typedef void (*VnThread_StartRoutine)(void*);
VnError VnThread_startNew(VnThread *thread, VnThread_StartRoutine startRoutine, void* routineData);
VnError VnThread_join(VnThread *thread);
void VnThread_sleepSec(uint32_t numOfSecsToSleep);
void VnThread_sleepMs(uint32_t numOfMsToSleep);
void VnThread_sleepUs(uint32_t numOfUsToSleep);
#ifdef __cplusplus
}
#endif
#endif
VnThread_join
VnError VnThread_join(VnThread *thread)
Blocks the calling thread until the referenced thread finishes.
VnThread_startNew
VnError VnThread_startNew(VnThread *thread, VnThread_StartRoutine startRoutine, void *routineData)
Starts a new thread immediately which calls the provided start routine.
VnThread_sleepMs
void VnThread_sleepMs(uint32_t numOfMsToSleep)
Causes the calling thread to sleep the specified number of milliseconds.
VnThread
Structure for working with threads.
Definition: thread.h:40
VnThread_sleepUs
void VnThread_sleepUs(uint32_t numOfUsToSleep)
Causes the calling thread to sleep the specified number of microseconds.
VnThread_sleepSec
void VnThread_sleepSec(uint32_t numOfSecsToSleep)
Causes the calling thread to sleep the specified number of seconds.
VnThread_StartRoutine
void(* VnThread_StartRoutine)(void *)
Function signature for a start routine for a thread.
Definition: thread.h:52