LibreOffice
LibreOffice 4.3 SDK C/C++ API Reference
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  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_OSL_CONDITN_HXX
21 #define INCLUDED_OSL_CONDITN_HXX
22 
23 #ifdef __cplusplus
24 
25 #include <osl/time.h>
26 
27 #include <osl/conditn.h>
28 
29 
30 namespace osl
31 {
40  class Condition
41  {
42  public:
43 
44  enum Result
45  {
49  };
50 
51  /* Create a condition.
52  */
54  {
55  condition = osl_createCondition();
56  }
57 
58  /* Release the OS-structures and free condition data-structure.
59  */
61  {
62  osl_destroyCondition(condition);
63  }
64 
65  /* Release all waiting threads, check returns true.
66  */
67  void set()
68  {
69  osl_setCondition(condition);
70  }
71 
72  /* Reset condition to false: wait() will block, check() returns false.
73  */
74  void reset() {
75  osl_resetCondition(condition);
76  }
77 
80  Result wait(const TimeValue *pTimeout = 0)
81  {
82  return (Result) osl_waitCondition(condition, pTimeout);
83  }
84 
87  bool check()
88  {
89  return osl_checkCondition(condition);
90  }
91 
92 
93  private:
94  oslCondition condition;
95 
102  Condition(const Condition&);
103 
110  Condition(oslCondition condition);
111 
115  Condition& operator= (const Condition&);
116 
120  Condition& operator= (oslCondition);
121  };
122 
123 }
124 
125 #endif /* __cplusplus */
126 #endif // INCLUDED_OSL_CONDITN_HXX
127 
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void set()
Definition: conditn.hxx:67
Result
Definition: conditn.hxx:44
SAL_DLLPUBLIC sal_Bool osl_checkCondition(oslCondition Condition)
Queries the state of the condition without blocking.
Definition: conditn.hxx:47
Warning: the Condition abstraction is inadequate for any situation where there may be multiple thread...
Definition: conditn.hxx:40
SAL_DLLPUBLIC oslConditionResult osl_waitCondition(oslCondition Condition, const TimeValue *pTimeout)
Blocks if condition is not set If condition has been destroyed prematurely, wait() will return with ...
SAL_DLLPUBLIC sal_Bool osl_resetCondition(oslCondition Condition)
Sets condition to False => wait() will block, check() returns False.
Condition()
Definition: conditn.hxx:53
Definition: time.h:42
SAL_DLLPUBLIC void osl_destroyCondition(oslCondition Condition)
Free the memory used by the condition.
~Condition()
Definition: conditn.hxx:60
bool check()
Checks if the condition is set without blocking.
Definition: conditn.hxx:87
Definition: conditn.h:36
Definition: conditn.hxx:30
SAL_DLLPUBLIC oslCondition osl_createCondition(void)
Creates a condition.
SAL_DLLPUBLIC sal_Bool osl_setCondition(oslCondition Condition)
Sets condition to True => wait() will not block, check() returns True.
Definition: conditn.hxx:48
Definition: conditn.hxx:46
void reset()
Definition: conditn.hxx:74
Definition: conditn.h:37
Definition: conditn.h:38
void * oslCondition
Definition: conditn.h:33
Result wait(const TimeValue *pTimeout=0)
Blocks the calling thread until condition is set.
Definition: conditn.hxx:80