merge the formfield patch from ooo-build
[ooovba.git] / sal / inc / osl / conditn.hxx
blobfb844a6b2b33ee533d248c3e29040b2f33944981
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: conditn.hxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _OSL_CONDITN_HXX_
32 #define _OSL_CONDITN_HXX_
34 #ifdef __cplusplus
36 #include <osl/time.h>
38 #include <osl/conditn.h>
41 namespace osl
44 class Condition
46 public:
48 enum Result
50 result_ok = osl_cond_result_ok,
51 result_error = osl_cond_result_error,
52 result_timeout = osl_cond_result_timeout
55 /* Create a condition.
57 Condition()
59 condition = osl_createCondition();
62 /* Release the OS-structures and free condition data-structure.
64 ~Condition()
66 osl_destroyCondition(condition);
69 /* Release all waiting threads, check returns sal_True.
71 void set()
73 osl_setCondition(condition);
76 /* Reset condition to false: wait() will block, check() returns sal_False.
78 void reset() {
79 osl_resetCondition(condition);
82 /** Blocks the calling thread until condition is set.
84 Result wait(const TimeValue *pTimeout = 0)
86 return (Result) osl_waitCondition(condition, pTimeout);
89 /** Checks if the condition is set without blocking.
91 sal_Bool check()
93 return osl_checkCondition(condition);
97 private:
98 oslCondition condition;
100 /** The underlying oslCondition has no reference count.
102 Since the underlying oslCondition is not a reference counted object, copy
103 constructed Condition may work on an already destructed oslCondition object.
106 Condition(const Condition&);
108 /** The underlying oslCondition has no reference count.
110 When destructed, the Condition object destroys the undelying oslCondition,
111 which might cause severe problems in case it's a temporary object.
114 Condition(oslCondition condition);
116 /** This assignment operator is private for the same reason as
117 the copy constructor.
119 Condition& operator= (const Condition&);
121 /** This assignment operator is private for the same reason as
122 the constructor taking a oslCondition argument.
124 Condition& operator= (oslCondition);
129 #endif /* __cplusplus */
130 #endif /* _OSL_CONDITN_HXX_ */