aboutsummaryrefslogtreecommitdiff
path: root/src/core/refcnt.h
blob: 29a91ea034c20d7a2662c371600f3b89bc030511 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Copyright 2025 Staysail Systems, Inc. <info@staysail.tech>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
// file was obtained (LICENSE.txt).  A copy of the license may also be
// found online at https://opensource.org/licenses/MIT.
//

#ifndef CORE_REFCNT_H
#define CORE_REFCNT_H

#include "defs.h"
#include "platform.h"

typedef struct {
	nni_atomic_int rc_cnt;
	void (*rc_fini)(void *);
	void *rc_data;
} nni_refcnt;

extern void nni_refcnt_init(
    nni_refcnt *rc, unsigned value, void *v, void (*fini)(void *));
extern void nni_refcnt_hold(nni_refcnt *rc);
extern void nni_refcnt_rele(nni_refcnt *rc);

#endif // CORE_REFCNT_H