LibreOffice LibreOffice 5.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 #include <sal/config.h>
24
25 #include <cstddef>
26
27 #include <osl/time.h>
28
29 #include <osl/conditn.h>
30
31
32 namespace osl
33 {
42 class Condition
43 {
44 public:
45
46 enum Result
47 {
48 result_ok = osl_cond_result_ok,
49 result_error = osl_cond_result_error,
50 result_timeout = osl_cond_result_timeout
51 };
52
53 /* Create a condition.
54 */
55 Condition()
56 {
57 condition = osl_createCondition();
58 }
59
60 /* Release the OS-structures and free condition data-structure.
61 */
62 ~Condition()
63 {
64 osl_destroyCondition(condition);
65 }
66
67 /* Release all waiting threads, check returns true.
68 */
69 void set()
70 {
71 osl_setCondition(condition);
72 }
73
74 /* Reset condition to false: wait() will block, check() returns false.
75 */
76 void reset() {
77 osl_resetCondition(condition);
78 }
79
82 Result wait(const TimeValue *pTimeout = NULL)
83 {
84 return (Result) osl_waitCondition(condition, pTimeout);
85 }
86
87 #if defined LIBO_INTERNAL_ONLY
88 Result wait(TimeValue const & timeout) { return wait(&timeout); }
89 #endif
90
93 bool check()
94 {
95 return osl_checkCondition(condition);
96 }
97
98
99 private:
100 oslCondition condition;
101
108 Condition(const Condition&) SAL_DELETED_FUNCTION;
109
113 Condition& operator= (const Condition&) SAL_DELETED_FUNCTION;
114 };
115
116 }
117
118 #endif // INCLUDED_OSL_CONDITN_HXX
119
120 /* 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:46
osl::Condition::result_ok
Definition: conditn.hxx:48
osl_cond_result_timeout
Definition: conditn.h:38
osl::Condition::result_error
Definition: conditn.hxx:49
osl_waitCondition
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 ...
oslCondition
void * oslCondition
Definition: conditn.h:33
TimeValue
Definition: time.h:70
osl::Condition::Condition
Condition()
Definition: conditn.hxx:55
SAL_DELETED_FUNCTION
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:410
osl::Condition::reset
void reset()
Definition: conditn.hxx:76
conditn.h
osl_resetCondition
SAL_DLLPUBLIC sal_Bool osl_resetCondition(oslCondition Condition)
Sets condition to False => wait() will block, check() returns False.
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:93
osl_createCondition
SAL_DLLPUBLIC oslCondition osl_createCondition(void)
Creates a condition.
osl::Condition::result_timeout
Definition: conditn.hxx:50
osl
Definition: conditn.hxx:32
osl::Condition::wait
Result wait(const TimeValue *pTimeout=NULL)
Blocks the calling thread until condition is set.
Definition: conditn.hxx:82
config.h
osl_cond_result_error
Definition: conditn.h:37
osl::Condition::~Condition
~Condition()
Definition: conditn.hxx:62
osl::Condition
Warning: the Condition abstraction is inadequate for any situation where there may be multiple thread...
Definition: conditn.hxx:42
osl_cond_result_ok
Definition: conditn.h:36
osl_checkCondition
SAL_DLLPUBLIC sal_Bool osl_checkCondition(oslCondition Condition)
Queries the state of the condition without blocking.
time.h