simple thread-safe implementation of refcount.
Showing
2 changed files
with
45 additions
and
0 deletions
include/mailutils/refcount.h
0 → 100644
1 | /* GNU mailutils - a suite of utilities for electronic mail | ||
2 | Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Lesser General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 2 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | Lesser General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Lesser General Public | ||
15 | License along with this library; if not, write to the Free Software | ||
16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ | ||
17 | |||
18 | #ifndef _MAILUTILS_REFCOUNT_H | ||
19 | #define _MAILUTILS_REFCOUNT_H | ||
20 | |||
21 | #include <mailutils/types.h> | ||
22 | |||
23 | #ifdef __cplusplus | ||
24 | extern "C" { | ||
25 | #endif | ||
26 | |||
27 | /* FIXME: Declaration should be hidden in mailutils/sys/refcount.h */ | ||
28 | struct _mu_refcount | ||
29 | { | ||
30 | unsigned int ref; | ||
31 | monitor_t lock; | ||
32 | }; | ||
33 | |||
34 | extern int mu_refcount_create __P ((mu_refcount_t *)); | ||
35 | extern void mu_refcount_destroy __P ((mu_refcount_t *)); | ||
36 | extern int mu_refcount_inc __P ((mu_refcount_t)); | ||
37 | extern int mu_refcount_dec __P ((mu_refcount_t)); | ||
38 | |||
39 | #ifdef __cplusplus | ||
40 | } | ||
41 | #endif | ||
42 | |||
43 | #endif /* _MAILUTILS_REFCOUNT_H */ |
... | @@ -59,6 +59,7 @@ struct _message; | ... | @@ -59,6 +59,7 @@ struct _message; |
59 | struct _mime; | 59 | struct _mime; |
60 | struct _mu_mailcap; | 60 | struct _mu_mailcap; |
61 | struct _mu_mailcap_entry; | 61 | struct _mu_mailcap_entry; |
62 | struct _mu_refcount; | ||
62 | struct _observable; | 63 | struct _observable; |
63 | struct _observer; | 64 | struct _observer; |
64 | struct _property; | 65 | struct _property; |
... | @@ -87,6 +88,7 @@ typedef struct _message *message_t; | ... | @@ -87,6 +88,7 @@ typedef struct _message *message_t; |
87 | typedef struct _mime *mime_t; | 88 | typedef struct _mime *mime_t; |
88 | typedef struct _mu_mailcap *mu_mailcap_t; | 89 | typedef struct _mu_mailcap *mu_mailcap_t; |
89 | typedef struct _mu_mailcap_entry *mu_mailcap_entry_t; | 90 | typedef struct _mu_mailcap_entry *mu_mailcap_entry_t; |
91 | typedef struct _mu_refcount *mu_refcount_t; | ||
90 | typedef struct _observable *observable_t; | 92 | typedef struct _observable *observable_t; |
91 | typedef struct _observer *observer_t; | 93 | typedef struct _observer *observer_t; |
92 | typedef struct _property *property_t; | 94 | typedef struct _property *property_t; | ... | ... |
-
Please register or sign in to post a comment