rllib
1
|
#include <rlthread.h>
Public Member Functions | |
rlThread (int max_semphore=1000) | |
virtual | ~rlThread () |
int | create (void *(*func)(void *), void *argument) |
int | trylock () |
int | lock () |
int | unlock () |
int | waitSemaphore () |
int | incrementSemaphore () |
int | join (void **status) |
int | cancel () |
void | threadExit (void *status) |
Public Attributes | |
pthread_t | tid |
pthread_attr_t | attr |
pthread_mutex_t | mutex |
WSEMAPHORE | semaphore |
Private Attributes | |
THREAD_PARAM | arg |
Thread functions based on POSIX threads.
Definition at line 38 of file rlthread.h.
rlThread::rlThread | ( | int | max_semphore = 1000 | ) |
Definition at line 18 of file rlthread.cpp.
|
virtual |
Definition at line 28 of file rlthread.cpp.
int rlThread::cancel | ( | ) |
int rlThread::create | ( | void *(*)(void *) | func, |
void * | argument | ||
) |
Create a new thread Your thread function looks like:
void *threadFunction(void *arg) { THREAD_PARAM *p = (THREAD_PARAM *) arg; YOUR_DATA *d = (YOUR_DATA *) p->user;
for(int i=0; i<50; i++) { p->thread->lock(); // do something critical printf("this is the thread\n"); p->thread->unlock(); }
return NULL; }
Definition at line 35 of file rlthread.cpp.
int rlThread::incrementSemaphore | ( | ) |
int rlThread::join | ( | void ** | status | ) |
int rlThread::lock | ( | ) |
void rlThread::threadExit | ( | void * | status | ) |
int rlThread::trylock | ( | ) |
Try to lock the mutex. return 0 if already locked return !0 if lock sucessfull
Definition at line 42 of file rlthread.cpp.
int rlThread::unlock | ( | ) |
Unlock the mutex.
Definition at line 52 of file rlthread.cpp.
int rlThread::waitSemaphore | ( | ) |
|
private |
Definition at line 112 of file rlthread.h.
pthread_attr_t rlThread::attr |
Definition at line 108 of file rlthread.h.
pthread_mutex_t rlThread::mutex |
Definition at line 109 of file rlthread.h.
WSEMAPHORE rlThread::semaphore |
Definition at line 110 of file rlthread.h.
pthread_t rlThread::tid |
Definition at line 107 of file rlthread.h.