1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #ifndef INCLUDED_OSL_CONDITN_H
22 #define INCLUDED_OSL_CONDITN_H
24 #include <sal/config.h>
27 #include <sal/saldllapi.h>
33 typedef void* oslCondition
;
36 osl_cond_result_ok
, /* successful completion */
37 osl_cond_result_error
, /* error occurred, check osl_getLastSocketError() for details */
38 osl_cond_result_timeout
, /* blocking operation timed out */
39 osl_cond_result_FORCE_EQUAL_SIZE
= SAL_MAX_ENUM
42 /** Creates a condition.
43 The condition is in the reset-state.
44 @returns 0 if condition could not be created.
46 SAL_DLLPUBLIC oslCondition SAL_CALL
osl_createCondition(void);
48 /** Free the memory used by the condition.
49 @param Condition the condition handle.
51 SAL_DLLPUBLIC
void SAL_CALL
osl_destroyCondition(oslCondition Condition
);
53 /** Sets condition to True => wait() will not block, check() returns True.
54 NOTE: ALL threads waiting on this condition are unblocked!
55 @param Condition handle to a created condition.
56 @return False if system-call failed.
58 SAL_DLLPUBLIC sal_Bool SAL_CALL
osl_setCondition(oslCondition Condition
);
60 /** Sets condition to False => wait() will block, check() returns False
61 @param Condition handle to a created condition.
62 @return False if system-call failed.
64 SAL_DLLPUBLIC sal_Bool SAL_CALL
osl_resetCondition(oslCondition Condition
);
66 /** Blocks if condition is not set<BR>
67 If condition has been destroyed prematurely, wait() will
69 @param Condition handle to a created condition.
70 @param pTimeout Tiemout value or NULL for infinite waiting
71 @return False if system-call failed.
73 SAL_DLLPUBLIC oslConditionResult SAL_CALL
osl_waitCondition(oslCondition Condition
, const TimeValue
* pTimeout
);
75 /** Queries the state of the condition without blocking.
76 @param Condition handle to a created condition.
77 @return True: condition is set. <BR>
78 False: condition is not set. <BR>
80 SAL_DLLPUBLIC sal_Bool SAL_CALL
osl_checkCondition(oslCondition Condition
);
86 #endif // INCLUDED_OSL_CONDITN_H
88 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */