xref: /trunk/main/sal/inc/osl/conditn.h (revision ffd38472365e95f6a578737bc9a5eb0fac624a86)
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 #ifndef _OSL_CONDITION_H_
23 #define _OSL_CONDITION_H_
24 
25 #include <osl/time.h>
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 typedef void* oslCondition;
32 
33 typedef enum {
34     osl_cond_result_ok,     /* successful completion */
35     osl_cond_result_error,  /* error occurred, check osl_getLastSocketError() for details */
36     osl_cond_result_timeout, /* blocking operation timed out */
37     osl_cond_result_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
38 } oslConditionResult;
39 
40 /** Creates a condition.
41     The condition is in the reset-state.
42     @returns 0 if condition could not be created.
43 */
44 oslCondition SAL_CALL osl_createCondition(void);
45 
46 /** Free the memory used by the condition.
47     @param Condition the condition handle.
48 */
49 void SAL_CALL osl_destroyCondition(oslCondition Condition);
50 
51 /** Sets condition to True => wait() will not block, check() returns True.
52     NOTE: ALL threads waiting on this condition are unblocked!
53     @param Condition handle to a created condition.
54     @return False if system-call failed.
55 */
56 sal_Bool SAL_CALL osl_setCondition(oslCondition Condition);
57 
58 /** Sets condition to False => wait() will block, check() returns False
59     @param Condition handle to a created condition.
60     @return False if system-call failed.
61 */
62 sal_Bool SAL_CALL osl_resetCondition(oslCondition Condition);
63 
64 /** Blocks if condition is not set<BR>
65     If condition has been destroyed prematurely, wait() will
66     return with False.
67     @param Condition handle to a created condition.
68     @param pTimeout Timeout value or NULL for infinite waiting
69     @return False if system-call failed.
70 */
71 oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const TimeValue* pTimeout);
72 
73 /** Queries the state of the condition without blocking.
74     @param Condition handle to a created condition.
75     @return True: condition is set. <BR>
76     False: condition is not set. <BR>
77 */
78 sal_Bool SAL_CALL osl_checkCondition(oslCondition Condition);
79 
80 #ifdef __cplusplus
81 }
82 #endif
83 
84 #endif /* _OSL_CONDITION_H_ */
85