1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_OSL_CONDITN_HXX
21 #define INCLUDED_OSL_CONDITN_HXX
23 #include "sal/config.h"
28 #include "osl/conditn.h"
30 #if defined(MACOSX) && defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES)
31 # if __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES == 1
38 /** Condition variable
40 A condition variable is essentially an object that is initially
41 cleared which a thread waits on until it is "set". It allows a
42 thread to synchronize execution by allowing other threads to wait
43 for the condition to change before that thread then continues
46 @deprecated use C++11's std::condition_variable instead
47 for a more robust and helpful condition.
49 @attention Warning: the Condition abstraction is inadequate for
50 any situation where there may be multiple threads setting,
51 waiting, and resetting the same condition. It can only be
52 used to synchronise interactions between two threads
53 cf. lost wakeups in http://www.cs.wustl.edu/~schmidt/win32-cv-1.html
60 result_ok
= osl_cond_result_ok
, /*!< Successful completion. */
61 result_error
= osl_cond_result_error
, /*!< Error occurred. @see osl_getLastSocketError() */
62 result_timeout
= osl_cond_result_timeout
/*!< Blocking operation timed out. */
65 /** Create a condition.
67 @deprecated use C++11's std::condition_variable instead
68 for a more robust and helpful condition.
72 condition
= osl_createCondition();
75 /** Release the OS-structures and free condition data-structure.
77 @deprecated use C++11's std::condition_variable instead
78 for a more robust and helpful condition.
82 osl_destroyCondition(condition
);
85 /** Release all waiting threads, check returns true.
87 @deprecated use C++11's std::condition_variable instead
88 for a more robust and helpful condition.
92 osl_setCondition(condition
);
95 /** Reset condition to false: wait() will block, check() returns
98 @deprecated use C++11's std::condition_variable instead
99 for a more robust and helpful condition.
102 osl_resetCondition(condition
);
105 /** Blocks the calling thread until condition is set.
107 @param [in] pTimeout Timeout to wait before ending the condition.
110 @retval result_ok finished successfully
111 @retval result_error error occurred
112 @retval result_timeout timed out
114 @deprecated use C++11's std::condition_variable instead
115 for a more robust and helpful condition.
117 Result
wait(const TimeValue
*pTimeout
= NULL
)
119 return static_cast<Result
>(osl_waitCondition(condition
, pTimeout
));
122 #if defined LIBO_INTERNAL_ONLY
123 Result
wait(TimeValue
const & timeout
) { return wait(&timeout
); }
126 /** Checks if the condition is set without blocking.
128 @retval true condition is set
129 @retval false condition is not set
131 @deprecated use C++11's std::condition_variable instead
132 for a more robust and helpful condition.
136 return osl_checkCondition(condition
);
141 oslCondition condition
; /*< condition variable */
145 The underlying oslCondition has no reference count.
147 Since the underlying oslCondition is not a reference counted
148 object, copy constructed Condition may work on an already
149 destructed oslCondition object.
151 @deprecated use C++11's std::condition_variable instead
152 for a more robust and helpful condition.
154 Condition(const Condition
& condition
) SAL_DELETED_FUNCTION
;
156 /** This assignment operator is deleted for the same reason as
157 the copy constructor.
159 @deprecated use C++11's std::condition_variable instead
160 for a more robust and helpful condition.
162 Condition
& operator= (const Condition
&) SAL_DELETED_FUNCTION
;
166 #endif // INCLUDED_OSL_CONDITN_HXX
168 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */