]> git.ipfire.org Git - thirdparty/strongswan.git/blame - src/libstrongswan/threading/mutex.h
Update copyright headers after acquisition by secunet
[thirdparty/strongswan.git] / src / libstrongswan / threading / mutex.h
CommitLineData
b1f35d06 1/*
eba64cef 2 * Copyright (C) 2008-2009 Tobias Brunner
b1f35d06 3 * Copyright (C) 2008 Martin Willi
19ef2aec
TB
4 *
5 * Copyright (C) secunet Security Networks AG
b1f35d06
TB
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * for more details.
16 */
17
eba64cef
TB
18/**
19 * @defgroup mutex mutex
20 * @{ @ingroup threading
21 */
22
b1f35d06
TB
23#ifndef THREADING_MUTEX_H_
24#define THREADING_MUTEX_H_
25
eba64cef
TB
26typedef struct mutex_t mutex_t;
27typedef enum mutex_type_t mutex_type_t;
b1f35d06 28
eba64cef
TB
29/**
30 * Type of mutex.
31 */
32enum mutex_type_t {
33 /** default mutex */
34 MUTEX_TYPE_DEFAULT = 0,
35 /** allow recursive locking of the mutex */
36 MUTEX_TYPE_RECURSIVE = 1,
b1f35d06
TB
37};
38
39/**
eba64cef 40 * Mutex wrapper implements simple, portable and advanced mutex functions.
b1f35d06 41 */
eba64cef 42struct mutex_t {
b1f35d06
TB
43
44 /**
eba64cef 45 * Acquire the lock to the mutex.
b1f35d06 46 */
eba64cef 47 void (*lock)(mutex_t *this);
b1f35d06
TB
48
49 /**
eba64cef 50 * Release the lock on the mutex.
b1f35d06 51 */
eba64cef 52 void (*unlock)(mutex_t *this);
b1f35d06
TB
53
54 /**
eba64cef 55 * Destroy a mutex instance.
b1f35d06 56 */
eba64cef 57 void (*destroy)(mutex_t *this);
b1f35d06
TB
58};
59
eba64cef
TB
60/**
61 * Create a mutex instance.
62 *
63 * @param type type of mutex to create
64 * @return unlocked mutex instance
65 */
66mutex_t *mutex_create(mutex_type_t type);
67
68#endif /** THREADING_MUTEX_H_ @} */
b1f35d06 69