libsc  2.8.7
The SC library provides support for parallel scientific applications.
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
sc_refcount.h
Go to the documentation of this file.
1 /*
2  This file is part of the SC Library.
3  The SC Library provides support for parallel scientific applications.
4 
5  Copyright (C) 2010 The University of Texas System
6  Additional copyright (C) 2011 individual authors
7 
8  The SC Library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Lesser General Public
10  License as published by the Free Software Foundation; either
11  version 2.1 of the License, or (at your option) any later version.
12 
13  The SC Library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public
19  License along with the SC Library; if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  02110-1301, USA.
22 */
23 
32 #ifndef SC_REFCOUNT_H
33 #define SC_REFCOUNT_H
34 
35 #include <sc.h>
36 
37 SC_EXTERN_C_BEGIN;
38 
42 typedef struct sc_refcount
43 {
46 
48  int refcount;
49 }
51 
64 
71 void sc_refcount_init (sc_refcount_t * rc, int package_id);
72 
78 sc_refcount_t *sc_refcount_new (int package_id);
79 
85 
92 
103 
110 
117 
118 SC_EXTERN_C_END;
119 
120 #endif /* !SC_REFCOUNT_H */
Support for process management (memory allocation, logging, etc.)
void sc_refcount_init(sc_refcount_t *rc, int package_id)
Initialize a reference counter to 1.
int sc_refcount_unref(sc_refcount_t *rc)
Decrease the reference counter and notify when it reaches zero.
void sc_refcount_init_invalid(sc_refcount_t *rc)
Initialize a well-defined but unusable reference counter.
int sc_refcount_is_active(const sc_refcount_t *rc)
Check whether a reference counter has a positive value.
struct sc_refcount sc_refcount_t
The refcount structure is declared in public so its size is known.
void sc_refcount_ref(sc_refcount_t *rc)
Increase a reference counter.
sc_refcount_t * sc_refcount_new(int package_id)
Create a new reference counter with count initialized to 1.
int sc_refcount_is_last(const sc_refcount_t *rc)
Check whether a reference counter has value one.
void sc_refcount_destroy(sc_refcount_t *rc)
Destroy a reference counter.
The refcount structure is declared in public so its size is known.
Definition: sc_refcount.h:43
int refcount
The reference count is always positive for a valid counter.
Definition: sc_refcount.h:48
int package_id
The sc package that uses this reference counter.
Definition: sc_refcount.h:45