Annotation of embedaddon/strongswan/src/libstrongswan/threading/spinlock.h, revision 1.1.1.1
1.1 misho 1: /*
2: * Copyright (C) 2012 Tobias Brunner
3: * HSR Hochschule fuer Technik Rapperswil
4: *
5: * This program is free software; you can redistribute it and/or modify it
6: * under the terms of the GNU General Public License as published by the
7: * Free Software Foundation; either version 2 of the License, or (at your
8: * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9: *
10: * This program is distributed in the hope that it will be useful, but
11: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13: * for more details.
14: */
15:
16: /**
17: * @defgroup spinlock spinlock
18: * @{ @ingroup threading
19: */
20:
21: #ifndef THREADING_SPINLOCK_H_
22: #define THREADING_SPINLOCK_H_
23:
24: typedef struct spinlock_t spinlock_t;
25:
26: /**
27: * Spin lock wrapper implements a lock with low overhead when the lock is held
28: * only for a short time (waiting wastes processor cycles, though).
29: *
30: * If native spin locks are not available regular mutexes are used as fallback.
31: */
32: struct spinlock_t {
33:
34: /**
35: * Acquire the lock.
36: */
37: void (*lock)(spinlock_t *this);
38:
39: /**
40: * Release the lock.
41: */
42: void (*unlock)(spinlock_t *this);
43:
44: /**
45: * Destroy the instance.
46: */
47: void (*destroy)(spinlock_t *this);
48: };
49:
50: /**
51: * Create a spin lock instance.
52: *
53: * @return unlocked instance
54: */
55: spinlock_t *spinlock_create();
56:
57: #endif /** THREADING_SPINLOCK_H_ @} */
58:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>