LibreOffice: osl/conditn.hxx Source File

LibreOffice LibreOffice 7.6 SDK C/C++ API Reference

Loading...
Searching...
No Matches
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
40namespace osl
41{
59 class Condition
60 {
61 public:
62 enum Result
63 {
64 result_ok = osl_cond_result_ok,
65 result_error = osl_cond_result_error,
66 result_timeout = osl_cond_result_timeout
67 };
68
74 Condition()
75 {
76 condition = osl_createCondition();
77 }
78
84 ~Condition()
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_DELETED_FUNCTION
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition types.h:378
config.h
time.h
conditn.h
osl_resetCondition
SAL_DLLPUBLIC sal_Bool osl_resetCondition(oslCondition Condition)
Sets condition to False => wait() will block, check() returns False.
osl_cond_result_error
@ osl_cond_result_error
Definition conditn.h:40
osl_cond_result_ok
@ osl_cond_result_ok
Definition conditn.h:39
osl_cond_result_timeout
@ osl_cond_result_timeout
Definition conditn.h:41
osl_createCondition
SAL_DLLPUBLIC oslCondition osl_createCondition(void)
Creates a condition.
osl_waitCondition
SAL_DLLPUBLIC oslConditionResult osl_waitCondition(oslCondition Condition, const TimeValue *pTimeout)
Blocks if condition is not set.
oslCondition
void * oslCondition
Definition conditn.h:36
osl_setCondition
SAL_DLLPUBLIC sal_Bool osl_setCondition(oslCondition Condition)
Sets condition to True => wait() will not block, check() returns True.
osl_checkCondition
SAL_DLLPUBLIC sal_Bool osl_checkCondition(oslCondition Condition)
Queries the state of the condition without blocking.
osl_destroyCondition
SAL_DLLPUBLIC void osl_destroyCondition(oslCondition Condition)
Free the memory used by the condition.
osl
Definition condition.hxx:31
osl::Condition
Condition variable.
Definition conditn.hxx:60
osl::Condition::Result
Result
Definition conditn.hxx:63
osl::Condition::result_error
@ result_error
Definition conditn.hxx:65
osl::Condition::result_ok
@ result_ok
Definition conditn.hxx:64
osl::Condition::result_timeout
@ result_timeout
Definition conditn.hxx:66
osl::Condition::reset
void reset()
Reset condition to false: wait() will block, check() returns false.
Definition conditn.hxx:105
osl::Condition::set
void set()
Release all waiting threads, check returns true.
Definition conditn.hxx:94
osl::Condition::check
bool check()
Checks if the condition is set without blocking.
Definition conditn.hxx:138
osl::Condition::Condition
Condition()
Create a condition.
Definition conditn.hxx:74
osl::Condition::~Condition
~Condition()
Release the OS-structures and free condition data-structure.
Definition conditn.hxx:84
osl::Condition::wait
Result wait(const TimeValue *pTimeout=NULL)
Blocks the calling thread until condition is set.
Definition conditn.hxx:121
TimeValue
Time since Jan-01-1970.
Definition time.h:76