xref: /trunk/main/sal/inc/osl/conditn.h (revision 86e1cf34)
19eab2a37SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
39eab2a37SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
49eab2a37SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
59eab2a37SAndrew Rist  * distributed with this work for additional information
69eab2a37SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
79eab2a37SAndrew Rist  * to you under the Apache License, Version 2.0 (the
89eab2a37SAndrew Rist  * "License"); you may not use this file except in compliance
99eab2a37SAndrew Rist  * with the License.  You may obtain a copy of the License at
109eab2a37SAndrew Rist  *
119eab2a37SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
129eab2a37SAndrew Rist  *
139eab2a37SAndrew Rist  * Unless required by applicable law or agreed to in writing,
149eab2a37SAndrew Rist  * software distributed under the License is distributed on an
159eab2a37SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
169eab2a37SAndrew Rist  * KIND, either express or implied.  See the License for the
179eab2a37SAndrew Rist  * specific language governing permissions and limitations
189eab2a37SAndrew Rist  * under the License.
199eab2a37SAndrew Rist  *
209eab2a37SAndrew Rist  *************************************************************/
219eab2a37SAndrew Rist 
229eab2a37SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir 
25cdf0e10cSrcweir #ifndef _OSL_CONDITION_H_
26cdf0e10cSrcweir #define _OSL_CONDITION_H_
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <osl/time.h>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #ifdef __cplusplus
31cdf0e10cSrcweir extern "C" {
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir 
34cdf0e10cSrcweir typedef void* oslCondition;
35cdf0e10cSrcweir 
36cdf0e10cSrcweir typedef enum {
37cdf0e10cSrcweir     osl_cond_result_ok,		/* successful completion */
38*86e1cf34SPedro Giffuni     osl_cond_result_error,  /* error occurred, check osl_getLastSocketError() for details */
39cdf0e10cSrcweir 	osl_cond_result_timeout, /* blocking operation timed out */
40cdf0e10cSrcweir 	osl_cond_result_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
41cdf0e10cSrcweir } oslConditionResult;
42cdf0e10cSrcweir 
43cdf0e10cSrcweir /** Creates a condition.
44cdf0e10cSrcweir 	The condition is in the reset-state.
45cdf0e10cSrcweir 	@returns 0 if condition could not be created.
46cdf0e10cSrcweir */
47cdf0e10cSrcweir oslCondition SAL_CALL osl_createCondition(void);
48cdf0e10cSrcweir 
49cdf0e10cSrcweir /** Free the memory used by the condition.
50cdf0e10cSrcweir 	@param Condition the condition handle.
51cdf0e10cSrcweir */
52cdf0e10cSrcweir void SAL_CALL osl_destroyCondition(oslCondition Condition);
53cdf0e10cSrcweir 
54cdf0e10cSrcweir /** Sets condition to True => wait() will not block, check() returns True.
55cdf0e10cSrcweir 	NOTE: ALL threads waiting on this condition are unblocked!
56cdf0e10cSrcweir 	@param Condition handle to a created condition.
57cdf0e10cSrcweir 	@return False if system-call failed.
58cdf0e10cSrcweir */
59cdf0e10cSrcweir sal_Bool SAL_CALL osl_setCondition(oslCondition Condition);
60cdf0e10cSrcweir 
61cdf0e10cSrcweir /** Sets condition to False => wait() will block, check() returns False
62cdf0e10cSrcweir 	@param Condition handle to a created condition.
63cdf0e10cSrcweir 	@return False if system-call failed.
64cdf0e10cSrcweir */
65cdf0e10cSrcweir sal_Bool SAL_CALL osl_resetCondition(oslCondition Condition);
66cdf0e10cSrcweir 
67cdf0e10cSrcweir /** Blocks if condition is not set<BR>
68cdf0e10cSrcweir 	If condition has been destroyed prematurely, wait() will
69cdf0e10cSrcweir 	return with False.
70cdf0e10cSrcweir 	@param Condition handle to a created condition.
71cdf0e10cSrcweir 	@param pTimeout Tiemout value or NULL for infinite waiting
72cdf0e10cSrcweir 	@return False if system-call failed.
73cdf0e10cSrcweir */
74cdf0e10cSrcweir oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const TimeValue* pTimeout);
75cdf0e10cSrcweir 
76cdf0e10cSrcweir /** Queries the state of the condition without blocking.
77cdf0e10cSrcweir 	@param Condition handle to a created condition.
78cdf0e10cSrcweir 	@return True: condition is set. <BR>
79cdf0e10cSrcweir 	False: condition is not set. <BR>
80cdf0e10cSrcweir */
81cdf0e10cSrcweir sal_Bool SAL_CALL osl_checkCondition(oslCondition Condition);
82cdf0e10cSrcweir 
83cdf0e10cSrcweir #ifdef __cplusplus
84cdf0e10cSrcweir }
85cdf0e10cSrcweir #endif
86cdf0e10cSrcweir 
87cdf0e10cSrcweir #endif /* _OSL_CONDITION_H_ */
88cdf0e10cSrcweir 
89