LibreOffice
LibreOffice 5.4 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 #include <sal/config.h>
24 
25 #include <cstddef>
26 
27 #include <osl/time.h>
28 
29 #include <osl/conditn.h>
30 
31 #if defined(MACOSX) && defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES)
32 # if __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES == 1
33 # undef check
34 # endif
35 #endif
36 
37 namespace osl
38 {
52  class Condition
53  {
54  public:
55 
56  enum Result
57  {
61  };
62 
70  {
71  condition = osl_createCondition();
72  }
73 
74  /* Release the OS-structures and free condition data-structure.
75  */
77  {
78  osl_destroyCondition(condition);
79  }
80 
81  /* Release all waiting threads, check returns true.
82  */
83  void set()
84  {
85  osl_setCondition(condition);
86  }
87 
88  /* Reset condition to false: wait() will block, check() returns false.
89  */
90  void reset() {
91  osl_resetCondition(condition);
92  }
93 
96  Result wait(const TimeValue *pTimeout = NULL)
97  {
98  return (Result) osl_waitCondition(condition, pTimeout);
99  }
100 
101 #if defined LIBO_INTERNAL_ONLY
102  Result wait(TimeValue const & timeout) { return wait(&timeout); }
103 #endif
104 
107  bool check()
108  {
109  return osl_checkCondition(condition);
110  }
111 
112 
113  private:
114  oslCondition condition;
115 
123 
127  Condition& operator= (const Condition&) SAL_DELETED_FUNCTION;
128  };
129 
130 }
131 
132 #endif // INCLUDED_OSL_CONDITN_HXX
133 
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC sal_Bool osl_setCondition(oslCondition Condition)
Sets condition to True => wait() will not block, check() returns True.
Result
Definition: conditn.hxx:56
Definition: conditn.hxx:58
Definition: conditn.h:37
Definition: conditn.hxx:59
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 F...
void * oslCondition
Definition: conditn.h:32
Definition: time.h:66
Condition()
Create a condition.
Definition: conditn.hxx:69
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:392
void reset()
Definition: conditn.hxx:90
SAL_DLLPUBLIC sal_Bool osl_resetCondition(oslCondition Condition)
Sets condition to False => wait() will block, check() returns False.
SAL_DLLPUBLIC void osl_destroyCondition(oslCondition Condition)
Free the memory used by the condition.
bool check()
Checks if the condition is set without blocking.
Definition: conditn.hxx:107
SAL_DLLPUBLIC oslCondition osl_createCondition(void)
Creates a condition.
Definition: conditn.hxx:60
Definition: conditn.hxx:37
Result wait(const TimeValue *pTimeout=NULL)
Blocks the calling thread until condition is set.
Definition: conditn.hxx:96
Definition: conditn.h:36
~Condition()
Definition: conditn.hxx:76
A deprecated condition.
Definition: conditn.hxx:52
Definition: conditn.h:35
SAL_DLLPUBLIC sal_Bool osl_checkCondition(oslCondition Condition)
Queries the state of the condition without blocking.