rlib
Convenience library for useful things
Loading...
Searching...
No Matches
rhzrptr.h
Go to the documentation of this file.
1/* RLIB - Convenience library for useful things
2 * Copyright (C) 2015 Haakon Sporsheim <haakon.sporsheim@gmail.com>
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 3.0 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.
16 * See the COPYING file at the root of the source repository.
17 */
18#ifndef __R_HZR_PTR_H__
19#define __R_HZR_PTR_H__
20
21#if !defined(__RLIB_H_INCLUDE_GUARD__) && !defined(RLIB_COMPILATION)
22#error "#include <rlib.h> only please."
23#endif
24
53#include <rlib/rtypes.h>
55
56
58
60#define R_HZR_PTR_INIT(notify) { 0, (RDestroyNotify)notify }
69typedef struct {
70 raptr ptr;
72} rhzrptr;
74typedef struct RHzrPtrRec RHzrPtrRec;
75
95
96
101
104#endif /* __R_HZR_PTR_H__ */
rpointer r_hzr_ptr_acquire(rhzrptr *hzrptr, RHzrPtrRec *rec)
Publish a hazard for the current value of hzrptr and return it.
RHzrPtrRec * r_hzr_ptr_rec_new(void)
Allocate a per-thread hazard record.
void r_hzr_ptr_release(rhzrptr *hzrptr, RHzrPtrRec *rec)
Drop the hazard published by a previous r_hzr_ptr_acquire.
struct RHzrPtrRec RHzrPtrRec
Opaque per-thread hazard record.
Definition rhzrptr.h:74
void r_hzr_ptr_replace(rhzrptr *hzrptr, rpointer ptr)
Atomically replace hzrptr's value with ptr and schedule the displaced value for delayed reclamation.
void r_hzr_ptr_rec_free(RHzrPtrRec *rec)
Free a per-thread hazard record at thread exit.
#define R_API
Public-API decoration: resolves to R_API_EXPORT while building rlib and R_API_IMPORT for consumers.
Definition rmacros.h:115
#define R_BEGIN_DECLS
Open an extern "C" block under C++ (no-op in C).
Definition rmacros.h:196
void(* RDestroyNotify)(rpointer ptr)
Destructor callback: free / release the value at ptr.
Definition rtypes.h:401
void * rpointer
Generic pointer (alias for void *).
Definition rtypes.h:327
Atomic load / store / exchange / CAS / fetch-modify operations on integer, unsigned-integer and point...
Foundational type aliases used by every rlib header.
Pointer slot that participates in hazard-pointer reclamation.
Definition rhzrptr.h:69
RDestroyNotify notify
Definition rhzrptr.h:71
raptr ptr
Definition rhzrptr.h:70