xref: /aoo4110/main/sal/inc/osl/mutex.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 #ifndef _OSL_MUTEX_H_
25 #define _OSL_MUTEX_H_
26 
27 #include <sal/types.h>
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 struct _oslMutexImpl;
34 typedef struct _oslMutexImpl * oslMutex;
35 
36 /** Create a thread-local mutex.
37 	@return 0 if the mutex could not be created, otherwise a handle to the mutex.
38 */
39 oslMutex SAL_CALL osl_createMutex(void);
40 
41 /** Release the OS-structures and free mutex data-structure.
42 	@param Mutex the mutex-handle
43 */
44 void SAL_CALL osl_destroyMutex(oslMutex Mutex);
45 
46 /** Acquire the mutex, block if already acquired by another thread.
47 	@param Mutex handle to a created mutex.
48 	@return False if system-call fails.
49 */
50 sal_Bool SAL_CALL osl_acquireMutex(oslMutex Mutex);
51 
52 /** Try to acquire the mutex without blocking.
53 	@param Mutex handle to a created mutex.
54 	@return False if it could not be acquired.
55 */
56 sal_Bool SAL_CALL osl_tryToAcquireMutex(oslMutex Mutex);
57 
58 /** Release the mutex.
59 	@param Mutex handle to a created mutex.
60 	@return False if system-call fails.
61 */
62 sal_Bool SAL_CALL osl_releaseMutex(oslMutex Mutex);
63 
64 /** Returns a unique and global mutex.
65 	@return the global mutex.
66 */
67 oslMutex * SAL_CALL osl_getGlobalMutex(void);
68 
69 #ifdef __cplusplus
70 }
71 #endif
72 
73 #endif	/* _OSL_MUTEX_H_ */
74