AlterOffice
AlterOffice 3.4 SDK C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
conditn.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 
3 
4 #ifndef INCLUDED_OSL_CONDITN_HXX
5 #define INCLUDED_OSL_CONDITN_HXX
6 
7 #include "sal/config.h"
8 
9 #include <cstddef>
10 
11 #include "osl/time.h"
12 #include "osl/conditn.h"
13 
14 #if defined(MACOSX) && defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES)
15 # if __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES == 1
16 # undef check
17 # endif
18 #endif
19 
20 namespace osl
21 {
39  class Condition
40  {
41  public:
42  enum Result
43  {
47  };
48 
55  {
56  condition = osl_createCondition();
57  }
58 
65  {
66  osl_destroyCondition(condition);
67  }
68 
74  void set()
75  {
76  osl_setCondition(condition);
77  }
78 
85  void reset() {
86  osl_resetCondition(condition);
87  }
88 
101  Result wait(const TimeValue *pTimeout = NULL)
102  {
103  return static_cast<Result>(osl_waitCondition(condition, pTimeout));
104  }
105 
106 #if defined LIBO_INTERNAL_ONLY
107  Result wait(TimeValue const & timeout) { return wait(&timeout); }
108 #endif
109 
118  bool check()
119  {
120  return osl_checkCondition(condition);
121  }
122 
123 
124  private:
125  oslCondition condition; /*< condition variable */
126 
138  Condition(const Condition& condition) SAL_DELETED_FUNCTION;
139 
146  Condition& operator= (const Condition&) SAL_DELETED_FUNCTION;
147  };
148 }
149 
150 #endif // INCLUDED_OSL_CONDITN_HXX
151 
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool check()
Checks if the condition is set without blocking.
Definition: conditn.hxx:118
Time since Jan-01-1970.
Definition: time.h:56
void reset()
Reset condition to false: wait() will block, check() returns false.
Definition: conditn.hxx:85
SAL_DLLPUBLIC void osl_destroyCondition(oslCondition Condition)
Free the memory used by the condition.
Definition: conditn.hxx:45
void * oslCondition
Definition: conditn.h:16
Definition: conditn.h:20
void set()
Release all waiting threads, check returns true.
Definition: conditn.hxx:74
SAL_DLLPUBLIC sal_Bool osl_checkCondition(oslCondition Condition)
Queries the state of the condition without blocking.
Condition variable.
Definition: conditn.hxx:39
Definition: conditn.hxx:46
SAL_DLLPUBLIC oslConditionResult osl_waitCondition(oslCondition Condition, const TimeValue *pTimeout)
Blocks if condition is not set.
~Condition()
Release the OS-structures and free condition data-structure.
Definition: conditn.hxx:64
Definition: conditn.h:21
SAL_DLLPUBLIC sal_Bool osl_resetCondition(oslCondition Condition)
Sets condition to False =&gt; wait() will block, check() returns False.
Definition: conditn.hxx:44
Result wait(const TimeValue *pTimeout=NULL)
Blocks the calling thread until condition is set.
Definition: conditn.hxx:101
Condition()
Create a condition.
Definition: conditn.hxx:54
SAL_DLLPUBLIC oslCondition osl_createCondition(void)
Creates a condition.
Result
Definition: conditn.hxx:42
SAL_DLLPUBLIC sal_Bool osl_setCondition(oslCondition Condition)
Sets condition to True =&gt; wait() will not block, check() returns True.
Definition: conditn.h:19
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:358