23#ifndef INCLUDED_vrpn_Thread_h_GUID_A455652F_72CE_4F8A_859E_543489012D01
24#define INCLUDED_vrpn_Thread_h_GUID_A455652F_72CE_4F8A_859E_543489012D01
27#include "vrpn_Configure.h"
34#if defined(sgi) || (defined(_WIN32) && !defined(__CYGWIN__)) || \
35 defined(linux) || defined(__APPLE__)
36#define vrpn_THREADS_AVAILABLE
38#undef vrpn_THREADS_AVAILABLE
55#pragma set woff 1110, 1424, 3201
60#pragma reset woff 1110, 1424, 3201
73 bool reset(
int cNumResources = 1);
107 static usptr_t *ppaArena;
108 static void allocArena();
153 void handleLockResult_(
int result);
194 typedef unsigned long thread_t;
196 typedef uintptr_t thread_t;
198 typedef pthread_t thread_t;
211 static bool available();
214 static unsigned number_of_processors();
220 void userData(
void *pvNewUserData);
229 static void threadFuncShell(
void *pvThread);
233 static void *threadFuncShellPosix(
void *pvThread);
240extern bool vrpn_test_threads_and_semaphores(
void);
An RAII lock/guard class for vrpn_Semaphore
定义 vrpn_Thread.h:129
bool try_to_lock()
Tries to lock - returns true if we locked it.
SemaphoreGuard(vrpn_Semaphore &sem, try_to_lock_t)
overload that only tries to lock (condP) - doesn't block.
bool locked() const
Checks to see if we locked.
定义 vrpn_Thread.h:141
void unlock()
Unlocks the resource, if we have locked it.
~SemaphoreGuard()
Destructor that unlocks if we've locked.
SemaphoreGuard(vrpn_Semaphore &sem)
Constructor that locks (p) the semaphore
void lock()
Locks the semaphore, if we haven't locked it already.
int condP()
Non-blocking attempt to acquire resource ("down")
bool reset(int cNumResources=1)
routine to reset it (true on success, false on failure) (may create new semaphore)
int p()
Blocking acquire of resource. ("down")
int numResources()
read values
int v()
Release of resource. ("up")
vrpn_Semaphore(int cNumResources=1)
constructor - mutex by default (0 is a sync primitive)
~vrpn_Semaphore()
destructor
const try_to_lock_t try_to_lock
Dummy variable to pass to SemaphoreGuard to indicate we only want a conditional lock.
定义 vrpn_Thread.h:127
Header to minimally include windows.h