Create Project for repo.or.cz
[vp.git] / src / utils / HLH_Cond.h
blob8438d7a1b6afd07ded172ee46737b6210021221b
1 /*******************************************************************************
2 * File : HLH_Cond.h
3 *
4 * Author : Henry He
5 * Created : 2009-10-8 11:46:20
6 * Description :
7 ******************************************************************************/
9 #ifndef __HLH_COND_INC_20091008_114620_HENRY__
10 #define __HLH_COND_INC_20091008_114620_HENRY__
13 /*******************************************************************************
14 * Desc : Includes Files
15 ******************************************************************************/
16 #include "utils/typedef.h"
17 #include "utils/HLH_RoundU32.h"
18 #include "utils/HLH_Time.h"
19 #include "utils/HLH_Mutex.h"
21 /*******************************************************************************
22 * Desc : Macro Definations
23 ******************************************************************************/
25 ////////////////////////////////////////////////////////////////////////////////
26 // Error Codes
28 #define HLH_COND_ERR_FAILED (-1)
29 #define HLH_COND_ERR_ALREADY_INITED (-2)
30 #define HLH_COND_ERR_NOT_INIT (-3)
31 #define HLH_COND_ERR_CANT_INIT (-4)
34 /*******************************************************************************
35 * Desc : Type Definations
36 ******************************************************************************/
39 /*******************************************************************************
40 * Desc : Global Variables
41 ******************************************************************************/
47 /*******************************************************************************
48 * Desc : Classes
49 ******************************************************************************/
51 class HLH_Cond
54 public:
55 /******************************************************************************
56 * Desc : Constructor / Deconstructor
57 ******************************************************************************/
58 HLH_Cond ();
59 ~ HLH_Cond ();
61 public:
62 /******************************************************************************
63 * Desc : Operations
64 ******************************************************************************/
66 // Init this condition
67 int Init ();
69 // Destroy this condition
70 void Destroy ();
72 // Wait for this condition
73 int Wait (HLH_Mutex &zhmMutex);
75 // Wait for this condition util time reach
76 int TimeWait (HLH_Mutex &zhmMutex, const HLH_Time &zhtTime);
78 // Signal condition is reach
79 int Signal ();
81 // Signal all the waiter condition is reach
82 int Broadcast ();
84 private:
85 /******************************************************************************
86 * Desc : Private Data
87 ******************************************************************************/
89 // Whether this instance initialized
90 bool m_bInited;
92 // Internal condtion of HLH_Cond
93 pthread_cond_t m_cCond;
102 #endif /* __HLH_COND_INC_20091008_114620_HENRY__ */