ZenLib
Thread.h
Go to the documentation of this file.
1/* Copyright (c) MediaArea.net SARL. All Rights Reserved.
2 *
3 * Use of this source code is governed by a zlib-style license that can
4 * be found in the License.txt file in the root of the source tree.
5 */
6
7//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
8//
9// Thread functions
10//
11//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
12
13//---------------------------------------------------------------------------
14#ifndef ZenLib_ThreadH
15#define ZenLib_ThreadH
16//---------------------------------------------------------------------------
17#include "ZenLib/Conf.h"
19#ifdef _WINDOWS
20 #undef Yield
21#endif
22//---------------------------------------------------------------------------
23
24namespace ZenLib
25{
26
27//***************************************************************************
28/// @brief Thread manipulation
29//***************************************************************************
30
31class Thread
32{
33public :
34 //Constructor/Destructor
36 virtual ~Thread ();
37
38 //Control
51
52 //Status
53 bool IsRunning();
55 bool IsExited();
56
57 //Configuration
58 void Priority_Set(int8s Priority); //-100 to +100
59
60 //Main Entry
61 virtual void Entry();
62
63 //Internal
64 returnvalue Internal_Exit(); //Do not use it
65
66protected :
67
68 //Communicating
69 void Sleep(std::size_t Millisecond);
70 void Yield();
71
72private :
73 //Internal
74 void* ThreadPointer;
75
76 //The possible states of the thread ("-->" shows all possible transitions from this state)
77 enum state
78 {
79 State_New, // didn't start execution yet (--> Running)
80 State_Running, // thread is running (--> Paused, Terminating)
81 State_Paused, // thread is temporarily suspended (--> Running)
82 State_Terminating, // thread should terminate a.s.a.p. (--> Terminated)
83 State_Terminated, // thread is terminated
84 };
85 state State;
87};
88
89} //NameSpace
90
91#endif
CriticalSection manipulation.
Definition CriticalSection.h:32
Thread manipulation.
Definition Thread.h:32
returnvalue Pause()
returnvalue Internal_Exit()
void Priority_Set(int8s Priority)
returnvalue ForceTerminate()
returnvalue Run()
returnvalue
Definition Thread.h:40
@ Resource
Definition Thread.h:44
@ Incoherent
Definition Thread.h:43
@ Ok
Definition Thread.h:41
@ IsNotRunning
Definition Thread.h:42
virtual ~Thread()
void Sleep(std::size_t Millisecond)
returnvalue RequestTerminate()
returnvalue RunAgain()
bool IsTerminating()
virtual void Entry()
Definition BitStream.h:24