LibreOffice
LibreOffice 24.2 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 /*
21  * This file is part of LibreOffice published API.
22  */
23 
24 #ifndef INCLUDED_OSL_CONDITN_HXX
25 #define INCLUDED_OSL_CONDITN_HXX
26 
27 #include "sal/config.h"
28 
29 #include <cstddef>
30 
31 #include "osl/time.h"
32 #include "osl/conditn.h"
33 
34 #if defined(MACOSX) && defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES)
35 # if __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES == 1
36 # undef check
37 # endif
38 #endif
39 
40 namespace osl
41 {
59  class Condition
60  {
61  public:
62  enum Result
63  {
67  };
68 
75  {
76  condition = osl_createCondition();
77  }
78 
85  {
86  osl_destroyCondition(condition);
87  }
88 
94  void set()
95  {
96  osl_setCondition(condition);
97  }
98 
105  void reset() {
106  osl_resetCondition(condition);
107  }
108 
121  Result wait(const TimeValue *pTimeout = NULL)
122  {
123  return static_cast<Result>(osl_waitCondition(condition, pTimeout));
124  }
125 
126 #if defined LIBO_INTERNAL_ONLY
127  Result wait(TimeValue const & timeout) { return wait(&timeout); }
128 #endif
129 
138  bool check()
139  {
140  return osl_checkCondition(condition);
141  }
142 
143 
144  private:
145  oslCondition condition; /*< condition variable */
146 
158  Condition(const Condition& condition) SAL_DELETED_FUNCTION;
159 
166  Condition& operator= (const Condition&) SAL_DELETED_FUNCTION;
167  };
168 }
169 
170 #endif // INCLUDED_OSL_CONDITN_HXX
171 
172 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC sal_Bool osl_resetCondition(oslCondition Condition)
Sets condition to False => wait() will block, check() returns False.
Definition: condition.hxx:31
Result
Definition: conditn.hxx:62
void * oslCondition
Definition: conditn.h:36
Condition variable.
Definition: conditn.hxx:59
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:378
Definition: conditn.h:41
SAL_DLLPUBLIC void osl_destroyCondition(oslCondition Condition)
Free the memory used by the condition.
Definition: conditn.hxx:65
Definition: conditn.hxx:66
~Condition()
Release the OS-structures and free condition data-structure.
Definition: conditn.hxx:84
SAL_DLLPUBLIC oslConditionResult osl_waitCondition(oslCondition Condition, const TimeValue *pTimeout)
Blocks if condition is not set.
bool check()
Checks if the condition is set without blocking.
Definition: conditn.hxx:138
SAL_DLLPUBLIC oslCondition osl_createCondition(void)
Creates a condition.
Definition: conditn.h:39
Result wait(const TimeValue *pTimeout=NULL)
Blocks the calling thread until condition is set.
Definition: conditn.hxx:121
Definition: conditn.h:40
Time since Jan-01-1970.
Definition: time.h:76
void reset()
Reset condition to false: wait() will block, check() returns false.
Definition: conditn.hxx:105
SAL_DLLPUBLIC sal_Bool osl_checkCondition(oslCondition Condition)
Queries the state of the condition without blocking.
SAL_DLLPUBLIC sal_Bool osl_setCondition(oslCondition Condition)
Sets condition to True => wait() will not block, check() returns True.
Condition()
Create a condition.
Definition: conditn.hxx:74
Definition: conditn.hxx:64