-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathhazard-pointer.h
48 lines (35 loc) · 1.43 KB
/
hazard-pointer.h
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
* hazard-pointer.h: Hazard pointer related code.
*
* (C) Copyright 2011 Novell, Inc
*/
#ifndef __MONO_HAZARD_POINTER_H__
#define __MONO_HAZARD_POINTER_H__
#include "fake-glib.h"
#include "mono-membar.h"
#define HAZARD_POINTER_COUNT 3
typedef struct {
gpointer hazard_pointers [HAZARD_POINTER_COUNT];
} MonoThreadHazardPointers;
typedef void (*MonoHazardousFreeFunc) (gpointer p);
void mono_thread_hazardous_free_or_queue (gpointer p, MonoHazardousFreeFunc free_func,
gboolean free_func_might_lock, gboolean lock_free_context) MONO_INTERNAL;
void mono_thread_hazardous_try_free_all (void) MONO_INTERNAL;
MonoThreadHazardPointers* mono_hazard_pointer_get (void) MONO_INTERNAL;
gpointer get_hazardous_pointer (gpointer volatile *pp, MonoThreadHazardPointers *hp, int hazard_index) MONO_INTERNAL;
#define mono_hazard_pointer_set(hp,i,v) \
do { g_assert ((i) >= 0 && (i) < HAZARD_POINTER_COUNT); \
(hp)->hazard_pointers [(i)] = (v); \
mono_memory_write_barrier (); \
} while (0)
#define mono_hazard_pointer_get_val(hp,i) \
((hp)->hazard_pointers [(i)])
#define mono_hazard_pointer_clear(hp,i) \
do { g_assert ((i) >= 0 && (i) < HAZARD_POINTER_COUNT); \
(hp)->hazard_pointers [(i)] = NULL; \
} while (0)
void mono_thread_attach (void);
void mono_thread_smr_init (void) MONO_INTERNAL;
void mono_thread_smr_cleanup (void) MONO_INTERNAL;
void mono_thread_hazardous_print_stats (void) MONO_INTERNAL;
#endif /*__MONO_HAZARD_POINTER_H__*/