xref: /aoo42x/main/sal/inc/osl/conditn.h (revision 9eab2a37)
1*9eab2a37SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9eab2a37SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9eab2a37SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9eab2a37SAndrew Rist  * distributed with this work for additional information
6*9eab2a37SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9eab2a37SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9eab2a37SAndrew Rist  * "License"); you may not use this file except in compliance
9*9eab2a37SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*9eab2a37SAndrew Rist  *
11*9eab2a37SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*9eab2a37SAndrew Rist  *
13*9eab2a37SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9eab2a37SAndrew Rist  * software distributed under the License is distributed on an
15*9eab2a37SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9eab2a37SAndrew Rist  * KIND, either express or implied.  See the License for the
17*9eab2a37SAndrew Rist  * specific language governing permissions and limitations
18*9eab2a37SAndrew Rist  * under the License.
19*9eab2a37SAndrew Rist  *
20*9eab2a37SAndrew Rist  *************************************************************/
21*9eab2a37SAndrew Rist 
22*9eab2a37SAndrew 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 */
38cdf0e10cSrcweir     osl_cond_result_error,  /* error occured, 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