ZenLib
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
"
18
#include "
ZenLib/CriticalSection.h
"
19
#ifdef _WINDOWS
20
#undef Yield
21
#endif
22
//---------------------------------------------------------------------------
23
24
namespace
ZenLib
25
{
26
27
//***************************************************************************
28
/// @brief Thread manipulation
29
//***************************************************************************
30
31
class
Thread
32
{
33
public :
34
//Constructor/Destructor
35
Thread
();
36
virtual
~Thread
();
37
38
//Control
39
enum
returnvalue
40
{
41
Ok
,
42
IsNotRunning
,
43
Incoherent
,
44
Resource
,
45
};
46
returnvalue
Run
();
47
returnvalue
RunAgain
();
48
returnvalue
Pause
();
49
returnvalue
RequestTerminate
();
50
returnvalue
ForceTerminate
();
51
52
//Status
53
bool
IsRunning
();
54
bool
IsTerminating
();
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
66
protected :
67
68
//Communicating
69
void
Sleep
(std::size_t Millisecond);
70
void
Yield
();
71
72
private :
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;
86
CriticalSection C;
87
};
88
89
}
//NameSpace
90
91
#endif
ZenLib::Thread::Pause
returnvalue Pause()
ZenLib::Thread::IsTerminating
bool IsTerminating()
ZenLib::Thread::Resource
@ Resource
Definition:
Thread.h:44
ZenLib::Thread::Run
returnvalue Run()
ZenLib::Thread::Sleep
void Sleep(std::size_t Millisecond)
ZenLib::Thread::Incoherent
@ Incoherent
Definition:
Thread.h:43
ZenLib::Thread::Priority_Set
void Priority_Set(int8s Priority)
ZenLib::Thread
Thread manipulation.
Definition:
Thread.h:31
ZenLib::Thread::Ok
@ Ok
Definition:
Thread.h:41
ZenLib::Thread::RequestTerminate
returnvalue RequestTerminate()
ZenLib::Thread::Thread
Thread()
ZenLib::Thread::IsNotRunning
@ IsNotRunning
Definition:
Thread.h:42
ZenLib::Thread::~Thread
virtual ~Thread()
Conf.h
ZenLib::Thread::returnvalue
returnvalue
Definition:
Thread.h:39
ZenLib::Thread::IsRunning
bool IsRunning()
ZenLib
Definition:
BitStream.h:23
ZenLib::Thread::IsExited
bool IsExited()
ZenLib::Thread::ForceTerminate
returnvalue ForceTerminate()
ZenLib::Thread::RunAgain
returnvalue RunAgain()
CriticalSection.h
ZenLib::Thread::Internal_Exit
returnvalue Internal_Exit()
ZenLib::Thread::Yield
void Yield()
ZenLib::Thread::Entry
virtual void Entry()
Generated by
1.8.17