Annotation of embedaddon/strongswan/src/libstrongswan/threading/thread_value.h, revision 1.1.1.1
1.1 misho 1: /*
2: * Copyright (C) 2009 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 thread_value thread_value
18: * @{ @ingroup threading
19: */
20:
21: #ifndef THREADING_THREAD_VALUE_H_
22: #define THREADING_THREAD_VALUE_H_
23:
24: #include <threading/thread.h>
25:
26: typedef struct thread_value_t thread_value_t;
27:
28: /**
29: * Wrapper for thread-specific values.
30: */
31: struct thread_value_t {
32:
33: /**
34: * Set a thread-specific value.
35: *
36: * @param val thread specific value
37: */
38: void (*set)(thread_value_t *this, void *val);
39:
40: /**
41: * Get a thread-specific value.
42: *
43: * @return the value specific to the current thread
44: */
45: void *(*get)(thread_value_t *this);
46:
47: /**
48: * Destroys this thread specific value wrapper. There is no check for
49: * non-NULL values which are currently assigned to the calling thread, no
50: * destructor is called.
51: */
52: void (*destroy)(thread_value_t *this);
53:
54: };
55:
56: /**
57: * Create a new thread-specific value wrapper.
58: *
59: * The optional destructor is called whenever a thread terminates, with the
60: * assigned value as argument. It is not called if that value is NULL.
61: *
62: * @param destructor destructor
63: * @return thread-specific value wrapper
64: */
65: thread_value_t *thread_value_create(thread_cleanup_t destructor);
66:
67: #endif /** THREADING_THREAD_VALUE_H_ @} */
68:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>