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