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