bump product version to 4.2.0.1
[LibreOffice.git] / include / osl / conditn.hxx
blob5ca0323c2aa8f380829deb12b1b428c531c3024c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #ifdef __cplusplus
25 #include <osl/time.h>
27 #include <osl/conditn.h>
30 namespace osl
33 class Condition
35 public:
37 enum Result
39 result_ok = osl_cond_result_ok,
40 result_error = osl_cond_result_error,
41 result_timeout = osl_cond_result_timeout
44 /* Create a condition.
46 Condition()
48 condition = osl_createCondition();
51 /* Release the OS-structures and free condition data-structure.
53 ~Condition()
55 osl_destroyCondition(condition);
58 /* Release all waiting threads, check returns sal_True.
60 void set()
62 osl_setCondition(condition);
65 /* Reset condition to false: wait() will block, check() returns sal_False.
67 void reset() {
68 osl_resetCondition(condition);
71 /** Blocks the calling thread until condition is set.
73 Result wait(const TimeValue *pTimeout = 0)
75 return (Result) osl_waitCondition(condition, pTimeout);
78 /** Checks if the condition is set without blocking.
80 sal_Bool check()
82 return osl_checkCondition(condition);
86 private:
87 oslCondition condition;
89 /** The underlying oslCondition has no reference count.
91 Since the underlying oslCondition is not a reference counted object, copy
92 constructed Condition may work on an already destructed oslCondition object.
95 Condition(const Condition&);
97 /** The underlying oslCondition has no reference count.
99 When destructed, the Condition object destroys the undelying oslCondition,
100 which might cause severe problems in case it's a temporary object.
103 Condition(oslCondition condition);
105 /** This assignment operator is private for the same reason as
106 the copy constructor.
108 Condition& operator= (const Condition&);
110 /** This assignment operator is private for the same reason as
111 the constructor taking a oslCondition argument.
113 Condition& operator= (oslCondition);
118 #endif /* __cplusplus */
119 #endif // INCLUDED_OSL_CONDITN_HXX
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */