Release ETL_@VERSION_MAJ@_@VERSION_MIN@_@VERSION_REV@
[synfig.git] / ETL / tags / ETL_@VERSION_MAJ@_@VERSION_MIN@_@VERSION_REV@ / ETL / _condition.h
1 /*! ========================================================================
2 ** Extended Template and Library
3 ** Mutex Abstraction Class Implementation
4 ** $Id$
5 **
6 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
7 **
8 ** This package is free software; you can redistribute it and/or
9 ** modify it under the terms of the GNU General Public License as
10 ** published by the Free Software Foundation; either version 2 of
11 ** the License, or (at your option) any later version.
12 **
13 ** This package is distributed in the hope that it will be useful,
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 ** General Public License for more details.
17 **
18 ** === N O T E S ===========================================================
19 **
20 ** This is an internal header file, included by other ETL headers.
21 ** You should not attempt to use it directly.
22 **
23 ** ========================================================================= */
24
25 /* === S T A R T =========================================================== */
26
27 #ifndef __ETL__CONDITION_H_
28 #define __ETL__CONDITION_H_
29
30 /* === H E A D E R S ======================================================= */
31
32 /* === M A C R O S ========================================================= */
33
34 /* === C L A S S E S & S T R U C T S ======================================= */
35
36 _ETL_BEGIN_NAMESPACE
37
38 class condition : private mutex
39 {
40         bool flag;
41 public:
42         condition()
43         { flag=false; }
44         ~condition()
45         { }
46         void operator()()
47         { flag=true; }
48         void wait()
49         {
50                 mutex::lock lock(*this);
51
52                 while(!flag)Yield();
53                 flag=false;
54         }
55         void wait_next()
56         {
57                 mutex::lock lock(*this);
58
59                 flag=false;
60                 while(!flag)Yield();
61         }
62 };
63
64 _ETL_END_NAMESPACE
65
66 /* === E X T E R N S ======================================================= */
67
68 /* === E N D =============================================================== */
69
70 #endif