xref: /aoo41x/main/sal/inc/osl/conditn.h (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 
29 #ifndef _OSL_CONDITION_H_
30 #define _OSL_CONDITION_H_
31 
32 #include <osl/time.h>
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 typedef void* oslCondition;
39 
40 typedef enum {
41     osl_cond_result_ok,		/* successful completion */
42     osl_cond_result_error,  /* error occured, check osl_getLastSocketError() for details */
43 	osl_cond_result_timeout, /* blocking operation timed out */
44 	osl_cond_result_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
45 } oslConditionResult;
46 
47 /** Creates a condition.
48 	The condition is in the reset-state.
49 	@returns 0 if condition could not be created.
50 */
51 oslCondition SAL_CALL osl_createCondition(void);
52 
53 /** Free the memory used by the condition.
54 	@param Condition the condition handle.
55 */
56 void SAL_CALL osl_destroyCondition(oslCondition Condition);
57 
58 /** Sets condition to True => wait() will not block, check() returns True.
59 	NOTE: ALL threads waiting on this condition are unblocked!
60 	@param Condition handle to a created condition.
61 	@return False if system-call failed.
62 */
63 sal_Bool SAL_CALL osl_setCondition(oslCondition Condition);
64 
65 /** Sets condition to False => wait() will block, check() returns False
66 	@param Condition handle to a created condition.
67 	@return False if system-call failed.
68 */
69 sal_Bool SAL_CALL osl_resetCondition(oslCondition Condition);
70 
71 /** Blocks if condition is not set<BR>
72 	If condition has been destroyed prematurely, wait() will
73 	return with False.
74 	@param Condition handle to a created condition.
75 	@param pTimeout Tiemout value or NULL for infinite waiting
76 	@return False if system-call failed.
77 */
78 oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const TimeValue* pTimeout);
79 
80 /** Queries the state of the condition without blocking.
81 	@param Condition handle to a created condition.
82 	@return True: condition is set. <BR>
83 	False: condition is not set. <BR>
84 */
85 sal_Bool SAL_CALL osl_checkCondition(oslCondition Condition);
86 
87 #ifdef __cplusplus
88 }
89 #endif
90 
91 #endif /* _OSL_CONDITION_H_ */
92 
93