LibreOffice LibreOffice 6.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 #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 #include "osl/conditn.h"
29
30 #if defined(MACOSX) && defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES)
31 # if __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES == 1
32 # undef check
33 # endif
34 #endif
35
36 namespace osl
37 {
55 class Condition
56 {
57 public:
58 enum Result
59 {
60 result_ok = osl_cond_result_ok,
61 result_error = osl_cond_result_error,
62 result_timeout = osl_cond_result_timeout
63 };
64
70 Condition()
71 {
72 condition = osl_createCondition();
73 }
74
80 ~Condition()
81 {
82 osl_destroyCondition(condition);
83 }
84
90 void set()
91 {
92 osl_setCondition(condition);
93 }
94
101 void reset() {
102 osl_resetCondition(condition);
103 }
104
117 Result wait(const TimeValue *pTimeout = NULL)
118 {
119 return static_cast<Result>(osl_waitCondition(condition, pTimeout));
120 }
121
122 #if defined LIBO_INTERNAL_ONLY
123 Result wait(TimeValue const & timeout) { return wait(&timeout); }
124 #endif
125
134 bool check()
135 {
136 return osl_checkCondition(condition);
137 }
138
139
140 private:
141 oslCondition condition; /*< condition variable */
142
154 Condition(const Condition& condition) SAL_DELETED_FUNCTION;
155
162 Condition& operator= (const Condition&) SAL_DELETED_FUNCTION;
163 };
164 }
165
166 #endif // INCLUDED_OSL_CONDITN_HXX
167
168 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
osl_setCondition
SAL_DLLPUBLIC sal_Bool osl_setCondition(oslCondition Condition)
Sets condition to True => wait() will not block, check() returns True.
osl::Condition::Result
Result
Definition: conditn.hxx:58
osl::Condition::reset
void reset()
Reset condition to false: wait() will block, check() returns false.
Definition: conditn.hxx:101
osl_cond_result_timeout
Definition: conditn.h:37
osl_waitCondition
SAL_DLLPUBLIC oslConditionResult osl_waitCondition(oslCondition Condition, const TimeValue *pTimeout)
Blocks if condition is not set.
oslCondition
void * oslCondition
Definition: conditn.h:32
osl::Condition::result_error
Definition: conditn.hxx:61
osl::Condition::Condition
Condition()
Create a condition.
Definition: conditn.hxx:70
SAL_DELETED_FUNCTION
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:396
conditn.h
osl_resetCondition
SAL_DLLPUBLIC sal_Bool osl_resetCondition(oslCondition Condition)
Sets condition to False => wait() will block, check() returns False.
osl::Condition::wait
Result wait(const TimeValue *pTimeout=NULL)
Blocks the calling thread until condition is set.
Definition: conditn.hxx:117
osl_destroyCondition
SAL_DLLPUBLIC void osl_destroyCondition(oslCondition Condition)
Free the memory used by the condition.
osl::Condition::check
bool check()
Checks if the condition is set without blocking.
Definition: conditn.hxx:134
osl::Condition::result_timeout
Definition: conditn.hxx:62
osl_createCondition
SAL_DLLPUBLIC oslCondition osl_createCondition(void)
Creates a condition.
TimeValue
Definition: time.h:66
osl::Condition::~Condition
~Condition()
Release the OS-structures and free condition data-structure.
Definition: conditn.hxx:80
config.h
osl_cond_result_error
Definition: conditn.h:36
osl
Definition: condition.hxx:28
osl::Condition::result_ok
Definition: conditn.hxx:60
osl_cond_result_ok
Definition: conditn.h:35
osl::Condition::set
void set()
Release all waiting threads, check returns true.
Definition: conditn.hxx:90
osl_checkCondition
SAL_DLLPUBLIC sal_Bool osl_checkCondition(oslCondition Condition)
Queries the state of the condition without blocking.
osl::Condition
Condition variable.
Definition: conditn.hxx:55
time.h