rllib  1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
rlthread.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  rlthread.cpp - description
3  -------------------
4  begin : Tue Jan 02 2001
5  copyright : (C) 2001 by R. Lehrig
6  email : lehrig@t-online.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This library is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as *
13  * published by the Free Software Foundation *
14  * *
15  ***************************************************************************/
16 #include "rlthread.h"
17 
18 rlThread::rlThread(int max_semaphore)
19 {
21  arg.thread = this;
22  arg.user = NULL;
24  rlwrapinit_semaphore(&semaphore, max_semaphore);
25  arg.running = 0;
26 }
27 
29 {
30  arg.running = 0;
33 }
34 
35 int rlThread::create(void *(*func)(void*), void *user)
36 {
37  arg.user = user;
38  arg.running = 1;
39  return rlwthread_create(&tid, &attr, func, &arg);
40 }
41 
43 {
45 }
46 
48 {
49  return rlwthread_mutex_lock(&mutex);
50 }
51 
53 {
55 }
56 
58 {
60 }
61 
63 {
65 }
66 
67 void rlThread::threadExit(void *status)
68 {
69  arg.running = 0;
70  rlwthread_exit(status);
71 }
72 
73 int rlThread::join(void **status)
74 {
75  return rlwthread_join(tid, status);
76 }
77 
79 {
80  arg.running = 0;
81  return rlwthread_cancel(tid);
82 }
83 
84 //------------ class rlMutex ----------------------------------------------
86 {
88 }
89 
91 {
93 }
94 
96 {
98 }
99 
101 {
102  return rlwthread_mutex_lock(&mutex);
103 }
104 
106 {
107  return rlwthread_mutex_unlock(&mutex);
108 }
109 
110 //------------ class rlSemaphore ------------------------------------------
111 rlSemaphore::rlSemaphore(int max_semaphore)
112 {
113  rlwrapinit_semaphore(&semaphore, max_semaphore);
114 }
115 
117 {
119 }
120 
122 {
124 }
125 
127 {
129 }