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
24#include <stdlib.h>
25
26namespace ZenLib
27{
28
29//***************************************************************************
30/// @brief Thread manipulation
31//***************************************************************************
32
33class Thread
34{
35public :
36 //Constructor/Destructor
38 virtual ~Thread ();
39
40 //Control
42 {
47 };
53
54 //Status
55 bool IsRunning();
57 bool IsExited();
58
59 //Configuration
60 void Priority_Set(int8s Priority); //-100 to +100
61
62 //Main Entry
63 virtual void Entry();
64
65 //Internal
66 returnvalue Internal_Exit(); //Do not use it
67
68protected :
69
70 //Communicating
71 void Sleep(std::size_t Millisecond);
72 void Yield();
73
74private :
75 //Internal
76 void* ThreadPointer;
77
78 //The possible states of the thread ("-->" shows all possible transitions from this state)
79 enum state
80 {
81 State_New, // didn't start execution yet (--> Running)
82 State_Running, // thread is running (--> Paused, Terminating)
83 State_Paused, // thread is temporarily suspended (--> Running)
84 State_Terminating, // thread should terminate a.s.a.p. (--> Terminated)
85 State_Terminated, // thread is terminated
86 };
87 state State;
89};
90
91} //NameSpace
92
93#endif
CriticalSection manipulation.
Definition: CriticalSection.h:32
Thread manipulation.
Definition: Thread.h:34
returnvalue Pause()
returnvalue Internal_Exit()
void Priority_Set(int8s Priority)
returnvalue ForceTerminate()
returnvalue Run()
returnvalue
Definition: Thread.h:42
@ Resource
Definition: Thread.h:46
@ Incoherent
Definition: Thread.h:45
@ Ok
Definition: Thread.h:43
@ IsNotRunning
Definition: Thread.h:44
virtual ~Thread()
void Sleep(std::size_t Millisecond)
returnvalue RequestTerminate()
returnvalue RunAgain()
bool IsTerminating()
virtual void Entry()
Definition: BitStream.h:24