Open Inventor Release 2024.2.1
 
Loading...
Searching...
No Matches
SbThread.h
1/*=======================================================================
2 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4 *** ***
5 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8 *** ***
9 *** RESTRICTED RIGHTS LEGEND ***
10 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15 *** ***
16 *** COPYRIGHT (C) 1996-2014 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : Julien Chaplier (MMM yyyy)
22** Modified by : Nicolas Daguise (MMM yyyy)
23** Modified by : David Beilloin (MMM yyyy)
24**=======================================================================*/
25
26
27#ifndef _TGS_SB_THREAD_H_
28#define _TGS_SB_THREAD_H_
29
30#include <Inventor/SbBase.h>
31#include <Inventor/STL/list>
32
33#if defined(_WIN32)
34#pragma warning( push )
35#pragma warning( disable: 4290 4251 )
36#endif
37
38class SbThreadMutex;
39
65{
66 public:
67
74 static SbThread* create( void *(threadRoutine)(void* _userData), void *structData);
75
80 static void destroy(SbThread *);
81
86 static void kill(SbThread *thread);
87
93
107 static int increasePriorityLevel( int value = 1 );
108
113 static int decreasePriorityLevel( int value = 1 );
114
118 static int getPriorityLevel();
119
124 static int setPriorityLevel( int );
125
130 static SbThreadId_t getCurrentThreadId();
131
139 static void setName(const SbThreadId_t &threadId, const char* threadName);
140
141private:
145 static bool switchThread();
146
150 SbBool isRunning() { return bIsRunning; }
151
155 static void sleep_ms( int dT_ms );
156
157
158 private:
159 SbThread(void);
160 ~SbThread(void);
161
162 // Launcher
163 static void * threadTaskLauncher( void *_threadLancher );
164 bool bIsRunning; // true while running (false after exit)
165
166private:
167
168#ifdef _WIN32
169 SbHandle threadHandle;
170#endif
171
172 SbThreadId_t threadId;
173 typedef std::list< SbThread* > SbThreadList;
174 static SbThread::SbThreadList m_threadList;
175 static SbThreadMutex m_threadListMutex;
176 bool m_mustStop;
177};
178
179
180#if defined(_WIN32)
181#pragma warning( pop )
182#endif
183
184#endif //_TGS_SB_THREAD_H_
185
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Portable thread ...
Definition SbThread.h:65
static SbBool isStopRequested()
Returns true if another thread or process requested termination of this thread.
static int increasePriorityLevel(int value=1)
Valid Priorities values and behavior are OS dependent.
static SbThread * create(void *(threadRoutine)(void *_userData), void *structData)
Creates a new thread.
static int decreasePriorityLevel(int value=1)
Decrease thread priority of value unit.
static void setName(const SbThreadId_t &threadId, const char *threadName)
Assign a debug name to a thread.
static SbThreadId_t getCurrentThreadId()
Returns a unique id identifying the current thread.
static void kill(SbThread *thread)
Signals the specified thread that it should terminate ASAP.
static int getPriorityLevel()
Return the priority of the current thread.
static int setPriorityLevel(int)
Set the priority of the current thread.
static void destroy(SbThread *)
Destroys the specified thread.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Portable mutex c...
int SbBool
Boolean type.
Definition SbBase.h:87