1 /* hazardpointer.c generated by valac 0.18.0, the Vala compiler
2 * generated from hazardpointer.vala, do not modify */
6 * Copyright (C) 2011 Maciej Piechotka
8 * This 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.
13 * This 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.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 * Maciej Piechotka <uzytkownik2@gmail.com>
27 #include <glib-object.h>
30 typedef struct _GeeHazardPointer GeeHazardPointer;
31 typedef struct _GeeHazardPointerNode GeeHazardPointerNode;
33 #define GEE_HAZARD_POINTER_TYPE_POLICY (gee_hazard_pointer_policy_get_type ())
35 #define GEE_TYPE_ABSTRACT_COLLECTION (gee_abstract_collection_get_type ())
36 #define GEE_ABSTRACT_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection))
37 #define GEE_ABSTRACT_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollectionClass))
38 #define GEE_IS_ABSTRACT_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_ABSTRACT_COLLECTION))
39 #define GEE_IS_ABSTRACT_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEE_TYPE_ABSTRACT_COLLECTION))
40 #define GEE_ABSTRACT_COLLECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollectionClass))
42 typedef struct _GeeAbstractCollection GeeAbstractCollection;
43 typedef struct _GeeAbstractCollectionClass GeeAbstractCollectionClass;
45 #define GEE_TYPE_ABSTRACT_LIST (gee_abstract_list_get_type ())
46 #define GEE_ABSTRACT_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_ABSTRACT_LIST, GeeAbstractList))
47 #define GEE_ABSTRACT_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEE_TYPE_ABSTRACT_LIST, GeeAbstractListClass))
48 #define GEE_IS_ABSTRACT_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_ABSTRACT_LIST))
49 #define GEE_IS_ABSTRACT_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEE_TYPE_ABSTRACT_LIST))
50 #define GEE_ABSTRACT_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEE_TYPE_ABSTRACT_LIST, GeeAbstractListClass))
52 typedef struct _GeeAbstractList GeeAbstractList;
53 typedef struct _GeeAbstractListClass GeeAbstractListClass;
55 #define GEE_TYPE_ABSTRACT_BIDIR_LIST (gee_abstract_bidir_list_get_type ())
56 #define GEE_ABSTRACT_BIDIR_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_ABSTRACT_BIDIR_LIST, GeeAbstractBidirList))
57 #define GEE_ABSTRACT_BIDIR_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEE_TYPE_ABSTRACT_BIDIR_LIST, GeeAbstractBidirListClass))
58 #define GEE_IS_ABSTRACT_BIDIR_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_ABSTRACT_BIDIR_LIST))
59 #define GEE_IS_ABSTRACT_BIDIR_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEE_TYPE_ABSTRACT_BIDIR_LIST))
60 #define GEE_ABSTRACT_BIDIR_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEE_TYPE_ABSTRACT_BIDIR_LIST, GeeAbstractBidirListClass))
62 typedef struct _GeeAbstractBidirList GeeAbstractBidirList;
63 typedef struct _GeeAbstractBidirListClass GeeAbstractBidirListClass;
65 #define GEE_TYPE_ARRAY_LIST (gee_array_list_get_type ())
66 #define GEE_ARRAY_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_ARRAY_LIST, GeeArrayList))
67 #define GEE_ARRAY_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEE_TYPE_ARRAY_LIST, GeeArrayListClass))
68 #define GEE_IS_ARRAY_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_ARRAY_LIST))
69 #define GEE_IS_ARRAY_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEE_TYPE_ARRAY_LIST))
70 #define GEE_ARRAY_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEE_TYPE_ARRAY_LIST, GeeArrayListClass))
72 typedef struct _GeeArrayList GeeArrayList;
73 typedef struct _GeeArrayListClass GeeArrayListClass;
74 typedef struct _GeeHazardPointerFreeNode GeeHazardPointerFreeNode;
75 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
77 #define GEE_TYPE_TRAVERSABLE (gee_traversable_get_type ())
78 #define GEE_TRAVERSABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_TRAVERSABLE, GeeTraversable))
79 #define GEE_IS_TRAVERSABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_TRAVERSABLE))
80 #define GEE_TRAVERSABLE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_TRAVERSABLE, GeeTraversableIface))
82 typedef struct _GeeTraversable GeeTraversable;
83 typedef struct _GeeTraversableIface GeeTraversableIface;
85 #define GEE_TRAVERSABLE_TYPE_STREAM (gee_traversable_stream_get_type ())
87 #define GEE_TYPE_LAZY (gee_lazy_get_type ())
88 #define GEE_LAZY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_LAZY, GeeLazy))
89 #define GEE_LAZY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEE_TYPE_LAZY, GeeLazyClass))
90 #define GEE_IS_LAZY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_LAZY))
91 #define GEE_IS_LAZY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEE_TYPE_LAZY))
92 #define GEE_LAZY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEE_TYPE_LAZY, GeeLazyClass))
94 typedef struct _GeeLazy GeeLazy;
95 typedef struct _GeeLazyClass GeeLazyClass;
97 #define GEE_TYPE_ITERATOR (gee_iterator_get_type ())
98 #define GEE_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_ITERATOR, GeeIterator))
99 #define GEE_IS_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_ITERATOR))
100 #define GEE_ITERATOR_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_ITERATOR, GeeIteratorIface))
102 typedef struct _GeeIterator GeeIterator;
103 typedef struct _GeeIteratorIface GeeIteratorIface;
105 #define GEE_TYPE_ITERABLE (gee_iterable_get_type ())
106 #define GEE_ITERABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_ITERABLE, GeeIterable))
107 #define GEE_IS_ITERABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_ITERABLE))
108 #define GEE_ITERABLE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_ITERABLE, GeeIterableIface))
110 typedef struct _GeeIterable GeeIterable;
111 typedef struct _GeeIterableIface GeeIterableIface;
113 #define GEE_TYPE_COLLECTION (gee_collection_get_type ())
114 #define GEE_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_COLLECTION, GeeCollection))
115 #define GEE_IS_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_COLLECTION))
116 #define GEE_COLLECTION_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_COLLECTION, GeeCollectionIface))
118 typedef struct _GeeCollection GeeCollection;
119 typedef struct _GeeCollectionIface GeeCollectionIface;
121 #define GEE_TYPE_QUEUE (gee_queue_get_type ())
122 #define GEE_QUEUE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_QUEUE, GeeQueue))
123 #define GEE_IS_QUEUE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_QUEUE))
124 #define GEE_QUEUE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_QUEUE, GeeQueueIface))
126 typedef struct _GeeQueue GeeQueue;
127 typedef struct _GeeQueueIface GeeQueueIface;
129 #define GEE_HAZARD_POINTER_TYPE_RELEASE_POLICY (gee_hazard_pointer_release_policy_get_type ())
131 #define GEE_TYPE_LINKED_LIST (gee_linked_list_get_type ())
132 #define GEE_LINKED_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_LINKED_LIST, GeeLinkedList))
133 #define GEE_LINKED_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEE_TYPE_LINKED_LIST, GeeLinkedListClass))
134 #define GEE_IS_LINKED_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_LINKED_LIST))
135 #define GEE_IS_LINKED_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEE_TYPE_LINKED_LIST))
136 #define GEE_LINKED_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEE_TYPE_LINKED_LIST, GeeLinkedListClass))
138 typedef struct _GeeLinkedList GeeLinkedList;
139 typedef struct _GeeLinkedListClass GeeLinkedListClass;
140 #define _g_destroy_func0(var) (((var == NULL) || (g_destroy_func == NULL)) ? NULL : (var = (g_destroy_func (var), NULL)))
141 #define _gee_hazard_pointer_free0(var) ((var == NULL) ? NULL : (var = (gee_hazard_pointer_free (var), NULL)))
142 typedef struct _GeeHazardPointerContext GeeHazardPointerContext;
144 #define GEE_TYPE_ABSTRACT_SET (gee_abstract_set_get_type ())
145 #define GEE_ABSTRACT_SET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_ABSTRACT_SET, GeeAbstractSet))
146 #define GEE_ABSTRACT_SET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEE_TYPE_ABSTRACT_SET, GeeAbstractSetClass))
147 #define GEE_IS_ABSTRACT_SET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_ABSTRACT_SET))
148 #define GEE_IS_ABSTRACT_SET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEE_TYPE_ABSTRACT_SET))
149 #define GEE_ABSTRACT_SET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEE_TYPE_ABSTRACT_SET, GeeAbstractSetClass))
151 typedef struct _GeeAbstractSet GeeAbstractSet;
152 typedef struct _GeeAbstractSetClass GeeAbstractSetClass;
154 #define GEE_TYPE_HASH_SET (gee_hash_set_get_type ())
155 #define GEE_HASH_SET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_HASH_SET, GeeHashSet))
156 #define GEE_HASH_SET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEE_TYPE_HASH_SET, GeeHashSetClass))
157 #define GEE_IS_HASH_SET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_HASH_SET))
158 #define GEE_IS_HASH_SET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEE_TYPE_HASH_SET))
159 #define GEE_HASH_SET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEE_TYPE_HASH_SET, GeeHashSetClass))
161 typedef struct _GeeHashSet GeeHashSet;
162 typedef struct _GeeHashSetClass GeeHashSetClass;
163 typedef struct _Block5Data Block5Data;
164 #define _g_free0(var) ((var == NULL) ? NULL : (var = (g_free (var), NULL)))
165 #define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
167 struct _GeeHazardPointer {
168 GeeHazardPointerNode* _node;
172 GEE_HAZARD_POINTER_POLICY_DEFAULT,
173 GEE_HAZARD_POINTER_POLICY_THREAD_EXIT,
174 GEE_HAZARD_POINTER_POLICY_TRY_FREE,
175 GEE_HAZARD_POINTER_POLICY_FREE,
176 GEE_HAZARD_POINTER_POLICY_TRY_RELEASE,
177 GEE_HAZARD_POINTER_POLICY_RELEASE
178 } GeeHazardPointerPolicy;
180 typedef gboolean (*GeeForallFunc) (gpointer g, void* user_data);
182 GEE_TRAVERSABLE_STREAM_YIELD,
183 GEE_TRAVERSABLE_STREAM_CONTINUE,
184 GEE_TRAVERSABLE_STREAM_END
185 } GeeTraversableStream;
187 typedef GeeTraversableStream (*GeeStreamFunc) (GeeTraversableStream state, GeeLazy* g, GeeLazy** lazy, void* user_data);
188 struct _GeeIteratorIface {
189 GTypeInterface parent_iface;
190 gboolean (*next) (GeeIterator* self);
191 gboolean (*has_next) (GeeIterator* self);
192 gpointer (*get) (GeeIterator* self);
193 void (*remove) (GeeIterator* self);
194 gboolean (*get_valid) (GeeIterator* self);
195 gboolean (*get_read_only) (GeeIterator* self);
198 typedef gpointer (*GeeFoldFunc) (gpointer g, gpointer a, void* user_data);
199 typedef gpointer (*GeeMapFunc) (gpointer g, void* user_data);
200 typedef gboolean (*GeePredicate) (gconstpointer g, void* user_data);
201 struct _GeeTraversableIface {
202 GTypeInterface parent_iface;
203 GType (*get_g_type) (GeeTraversable* self);
204 GBoxedCopyFunc (*get_g_dup_func) (GeeTraversable* self);
205 GDestroyNotify (*get_g_destroy_func) (GeeTraversable* self);
206 gboolean (*foreach) (GeeTraversable* self, GeeForallFunc f, void* f_target);
207 GeeIterator* (*stream) (GeeTraversable* self, GType a_type, GBoxedCopyFunc a_dup_func, GDestroyNotify a_destroy_func, GeeStreamFunc f, void* f_target, GDestroyNotify f_target_destroy_notify);
208 gpointer (*fold) (GeeTraversable* self, GType a_type, GBoxedCopyFunc a_dup_func, GDestroyNotify a_destroy_func, GeeFoldFunc f, void* f_target, gpointer seed);
209 GeeIterator* (*map) (GeeTraversable* self, GType a_type, GBoxedCopyFunc a_dup_func, GDestroyNotify a_destroy_func, GeeMapFunc f, void* f_target);
210 GeeIterator* (*scan) (GeeTraversable* self, GType a_type, GBoxedCopyFunc a_dup_func, GDestroyNotify a_destroy_func, GeeFoldFunc f, void* f_target, gpointer seed);
211 GeeIterator* (*filter) (GeeTraversable* self, GeePredicate pred, void* pred_target, GDestroyNotify pred_target_destroy_notify);
212 GeeIterator* (*chop) (GeeTraversable* self, gint offset, gint length);
213 GType (*get_element_type) (GeeTraversable* self);
216 struct _GeeIterableIface {
217 GTypeInterface parent_iface;
218 GType (*get_g_type) (GeeIterable* self);
219 GBoxedCopyFunc (*get_g_dup_func) (GeeIterable* self);
220 GDestroyNotify (*get_g_destroy_func) (GeeIterable* self);
221 GeeIterator* (*iterator) (GeeIterable* self);
224 struct _GeeCollectionIface {
225 GTypeInterface parent_iface;
226 GType (*get_g_type) (GeeCollection* self);
227 GBoxedCopyFunc (*get_g_dup_func) (GeeCollection* self);
228 GDestroyNotify (*get_g_destroy_func) (GeeCollection* self);
229 gboolean (*contains) (GeeCollection* self, gconstpointer item);
230 gboolean (*add) (GeeCollection* self, gconstpointer item);
231 gboolean (*remove) (GeeCollection* self, gconstpointer item);
232 void (*clear) (GeeCollection* self);
233 gboolean (*add_all) (GeeCollection* self, GeeCollection* collection);
234 gboolean (*contains_all) (GeeCollection* self, GeeCollection* collection);
235 gboolean (*remove_all) (GeeCollection* self, GeeCollection* collection);
236 gboolean (*retain_all) (GeeCollection* self, GeeCollection* collection);
237 gpointer* (*to_array) (GeeCollection* self, int* result_length1);
238 gint (*get_size) (GeeCollection* self);
239 gboolean (*get_is_empty) (GeeCollection* self);
240 gboolean (*get_read_only) (GeeCollection* self);
241 GeeCollection* (*get_read_only_view) (GeeCollection* self);
244 struct _GeeQueueIface {
245 GTypeInterface parent_iface;
246 GType (*get_g_type) (GeeQueue* self);
247 GBoxedCopyFunc (*get_g_dup_func) (GeeQueue* self);
248 GDestroyNotify (*get_g_destroy_func) (GeeQueue* self);
249 gboolean (*offer) (GeeQueue* self, gconstpointer element);
250 gpointer (*peek) (GeeQueue* self);
251 gpointer (*poll) (GeeQueue* self);
252 gint (*drain) (GeeQueue* self, GeeCollection* recipient, gint amount);
253 gint (*get_capacity) (GeeQueue* self);
254 gint (*get_remaining_capacity) (GeeQueue* self);
255 gboolean (*get_is_full) (GeeQueue* self);
259 GEE_HAZARD_POINTER_RELEASE_POLICY_HELPER_THREAD,
260 GEE_HAZARD_POINTER_RELEASE_POLICY_MAIN_LOOP
261 } GeeHazardPointerReleasePolicy;
263 typedef gboolean (*GeeEqualDataFunc) (gconstpointer a, gconstpointer b, void* user_data);
264 typedef void (*GeeHazardPointerDestroyNotify) (void* ptr, void* user_data);
265 typedef guint (*GeeHashDataFunc) (gconstpointer v, void* user_data);
266 struct _GeeHazardPointerFreeNode {
268 GeeHazardPointerDestroyNotify destroy_notify;
269 gpointer destroy_notify_target;
270 GDestroyNotify destroy_notify_target_destroy_notify;
276 GBoxedCopyFunc g_dup_func;
277 GDestroyNotify g_destroy_func;
280 struct _GeeHazardPointerContext {
281 GeeHazardPointerContext* _parent;
282 GeeArrayList* _to_free;
283 GeeHazardPointerPolicy* _policy;
286 struct _GeeHazardPointerNode {
287 GeeHazardPointerNode* _next;
293 extern gint gee_hazard_pointer__default_policy;
294 extern gint gee_hazard_pointer__thread_exit_policy;
295 extern GStaticMutex gee_hazard_pointer__queue_mutex;
296 extern GeeQueue* gee_hazard_pointer__queue;
297 extern gint gee_hazard_pointer_release_policy;
298 extern GeeArrayList* gee_hazard_pointer__global_to_free;
299 extern GeeHazardPointerNode* gee_hazard_pointer__head;
300 GeeHazardPointerNode* gee_hazard_pointer__head = NULL;
301 gint gee_hazard_pointer__default_policy = (gint) GEE_HAZARD_POINTER_POLICY_TRY_FREE;
302 gint gee_hazard_pointer__thread_exit_policy = (gint) GEE_HAZARD_POINTER_POLICY_RELEASE;
303 gint gee_hazard_pointer_release_policy = 0;
304 GeeQueue* gee_hazard_pointer__queue = NULL;
305 GStaticMutex gee_hazard_pointer__queue_mutex = G_STATIC_MUTEX_INIT;
306 GeeArrayList* gee_hazard_pointer__global_to_free = NULL;
307 static guint gee_hazard_pointer_context_THRESHOLD;
308 extern GStaticPrivate gee_hazard_pointer_context__current_context;
309 GStaticPrivate gee_hazard_pointer_context__current_context = G_STATIC_PRIVATE_INIT;
310 extern GStaticPrivate gee_hazard_pointer_context__root_context;
311 GStaticPrivate gee_hazard_pointer_context__root_context = G_STATIC_PRIVATE_INIT;
312 static guint gee_hazard_pointer_context_THRESHOLD = (guint) 10;
314 void gee_hazard_pointer_free (GeeHazardPointer* self);
315 void gee_hazard_pointer_node_free (GeeHazardPointerNode* self);
316 static void gee_hazard_pointer_instance_init (GeeHazardPointer * self);
317 void gee_hazard_pointer_node_release (GeeHazardPointerNode* self);
318 GType gee_hazard_pointer_policy_get_type (void) G_GNUC_CONST;
319 gboolean gee_hazard_pointer_policy_is_concrete (GeeHazardPointerPolicy self);
320 gboolean gee_hazard_pointer_policy_is_blocking (GeeHazardPointerPolicy self);
321 gboolean gee_hazard_pointer_policy_is_safe (GeeHazardPointerPolicy self);
322 GeeHazardPointerPolicy gee_hazard_pointer_policy_to_concrete (GeeHazardPointerPolicy self);
323 GType gee_abstract_collection_get_type (void) G_GNUC_CONST;
324 GType gee_abstract_list_get_type (void) G_GNUC_CONST;
325 GType gee_abstract_bidir_list_get_type (void) G_GNUC_CONST;
326 GType gee_array_list_get_type (void) G_GNUC_CONST;
327 void gee_hazard_pointer_free_node_free (GeeHazardPointerFreeNode* self);
328 GeeArrayList* gee_hazard_pointer_policy_perform (GeeHazardPointerPolicy self, GeeArrayList* to_free);
329 gboolean gee_hazard_pointer_try_free (GeeArrayList* to_free);
330 void gee_hazard_pointer_release_policy_ensure_start (void);
331 GType gee_traversable_stream_get_type (void) G_GNUC_CONST;
332 gpointer gee_lazy_ref (gpointer instance);
333 void gee_lazy_unref (gpointer instance);
334 GParamSpec* gee_param_spec_lazy (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
335 void gee_value_set_lazy (GValue* value, gpointer v_object);
336 void gee_value_take_lazy (GValue* value, gpointer v_object);
337 gpointer gee_value_get_lazy (const GValue* value);
338 GType gee_lazy_get_type (void) G_GNUC_CONST;
339 GType gee_iterator_get_type (void) G_GNUC_CONST;
340 GType gee_traversable_get_type (void) G_GNUC_CONST;
341 GType gee_iterable_get_type (void) G_GNUC_CONST;
342 GType gee_collection_get_type (void) G_GNUC_CONST;
343 GType gee_queue_get_type (void) G_GNUC_CONST;
344 gboolean gee_queue_offer (GeeQueue* self, gconstpointer element);
345 GType gee_hazard_pointer_release_policy_get_type (void) G_GNUC_CONST;
346 static void gee_hazard_pointer_release_policy_start (GeeHazardPointerReleasePolicy _self_);
347 static gboolean ___lambda33_ (void);
348 static inline void gee_hazard_pointer_release_policy_attempt_free (void);
349 static gpointer ____lambda33__gthread_func (gpointer self);
350 static gboolean ___lambda35_ (void);
351 static gboolean ____lambda35__gsource_func (gpointer self);
352 GeeLinkedList* gee_linked_list_new (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, GeeEqualDataFunc equal_func, void* equal_func_target, GDestroyNotify equal_func_target_destroy_notify);
353 GeeLinkedList* gee_linked_list_construct (GType object_type, GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, GeeEqualDataFunc equal_func, void* equal_func_target, GDestroyNotify equal_func_target_destroy_notify);
354 GType gee_linked_list_get_type (void) G_GNUC_CONST;
355 GeeArrayList* gee_array_list_new (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, GeeEqualDataFunc equal_func, void* equal_func_target, GDestroyNotify equal_func_target_destroy_notify);
356 GeeArrayList* gee_array_list_construct (GType object_type, GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, GeeEqualDataFunc equal_func, void* equal_func_target, GDestroyNotify equal_func_target_destroy_notify);
357 gint gee_queue_drain (GeeQueue* self, GeeCollection* recipient, gint amount);
358 gboolean gee_traversable_foreach (GeeTraversable* self, GeeForallFunc f, void* f_target);
359 static gboolean ___lambda34_ (GeeArrayList* x);
360 gboolean gee_array_list_add_all (GeeArrayList* self, GeeCollection* collection);
361 static gboolean ____lambda34__gee_forall_func (gpointer g, gpointer self);
362 GeeHazardPointer* gee_hazard_pointer_new (gconstpointer* ptr);
363 GeeHazardPointer* gee_hazard_pointer_new (gconstpointer* ptr);
364 GeeHazardPointerNode* gee_hazard_pointer_acquire (void);
365 void gee_hazard_pointer_node_set (GeeHazardPointerNode* self, void* ptr);
366 GeeHazardPointer* gee_hazard_pointer_new_from_node (GeeHazardPointerNode* node);
367 GeeHazardPointer* gee_hazard_pointer_new_from_node (GeeHazardPointerNode* node);
368 GeeHazardPointer* gee_hazard_pointer_get_hazard_pointer (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, gconstpointer** aptr, gsize mask, gsize* mask_out);
369 gpointer gee_hazard_pointer_get_pointer (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, gconstpointer** aptr, gsize mask, gsize* mask_out);
370 GeeHazardPointer* gee_hazard_pointer_exchange_hazard_pointer (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, gconstpointer** aptr, gpointer new_ptr, gsize mask, gsize new_mask, gsize* old_mask);
371 void gee_hazard_pointer_set_pointer (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, gconstpointer** aptr, gpointer new_ptr, gsize mask, gsize new_mask);
372 GeeHazardPointerDestroyNotify gee_hazard_pointer_get_destroy_notify (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, void** result_target, GDestroyNotify* result_target_destroy_notify);
373 void gee_hazard_pointer_release (GeeHazardPointer* self, GeeHazardPointerDestroyNotify notify, void* notify_target, GDestroyNotify notify_target_destroy_notify);
374 gpointer gee_hazard_pointer_exchange_pointer (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, gconstpointer** aptr, gpointer new_ptr, gsize mask, gsize new_mask, gsize* old_mask);
375 gconstpointer gee_hazard_pointer_get (GeeHazardPointer* self, gboolean other_thread);
376 gboolean gee_hazard_pointer_compare_and_exchange_pointer (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, gconstpointer** aptr, gconstpointer old_ptr, gpointer _new_ptr, gsize mask, gsize old_mask, gsize new_mask);
377 void gee_hazard_pointer_context_free (GeeHazardPointerContext* self);
378 GeeHazardPointerContext* gee_hazard_pointer_context_get_current_context (void);
379 void gee_hazard_pointer_context_release_ptr (GeeHazardPointerContext* self, void* ptr, GeeHazardPointerDestroyNotify notify, void* notify_target, GDestroyNotify notify_target_destroy_notify);
380 void* gee_hazard_pointer_node_get (GeeHazardPointerNode* self, gboolean safe);
381 void gee_hazard_pointer_set_default_policy (GeeHazardPointerPolicy policy);
382 void gee_hazard_pointer_set_thread_exit_policy (GeeHazardPointerPolicy policy);
383 gboolean gee_hazard_pointer_set_release_policy (GeeHazardPointerReleasePolicy policy);
384 GeeHazardPointerNode* gee_hazard_pointer_get_head (void);
385 GeeHazardPointerNode* gee_hazard_pointer_node_get_next (GeeHazardPointerNode* self);
386 gboolean gee_hazard_pointer_node_activate (GeeHazardPointerNode* self);
387 GeeHazardPointerNode* gee_hazard_pointer_node_new (void);
388 GeeHazardPointerNode* gee_hazard_pointer_node_new (void);
389 void gee_hazard_pointer_node_set_next (GeeHazardPointerNode* self, GeeHazardPointerNode* next);
390 GeeHashSet* gee_hash_set_new (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, GeeHashDataFunc hash_func, void* hash_func_target, GDestroyNotify hash_func_target_destroy_notify, GeeEqualDataFunc equal_func, void* equal_func_target, GDestroyNotify equal_func_target_destroy_notify);
391 GeeHashSet* gee_hash_set_construct (GType object_type, GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, GeeHashDataFunc hash_func, void* hash_func_target, GDestroyNotify hash_func_target_destroy_notify, GeeEqualDataFunc equal_func, void* equal_func_target, GDestroyNotify equal_func_target_destroy_notify);
392 GType gee_abstract_set_get_type (void) G_GNUC_CONST;
393 GType gee_hash_set_get_type (void) G_GNUC_CONST;
394 gboolean gee_collection_add (GeeCollection* self, gconstpointer item);
395 gint gee_abstract_collection_get_size (GeeAbstractCollection* self);
396 gpointer gee_abstract_list_get (GeeAbstractList* self, gint index);
397 gboolean gee_collection_contains (GeeCollection* self, gconstpointer item);
398 gpointer gee_abstract_list_remove_at (GeeAbstractList* self, gint index);
399 void gee_abstract_list_set (GeeAbstractList* self, gint index, gconstpointer item);
400 static Block5Data* block5_data_ref (Block5Data* _data5_);
401 static void block5_data_unref (void * _userdata_);
402 static void __lambda36_ (Block5Data* _data5_, void* ptr);
403 static void ___lambda36__gee_hazard_pointer_destroy_notify (void* ptr, gpointer self);
404 static void gee_hazard_pointer_context_instance_init (GeeHazardPointerContext * self);
405 GeeHazardPointerContext* gee_hazard_pointer_context_new (GeeHazardPointerPolicy* policy);
406 GeeHazardPointerContext* gee_hazard_pointer_context_new (GeeHazardPointerPolicy* policy);
407 static GeeHazardPointerPolicy* _gee_hazard_pointer_policy_dup (GeeHazardPointerPolicy* self);
408 void gee_hazard_pointer_context_try_free (GeeHazardPointerContext* self);
409 void gee_hazard_pointer_context_free_all (GeeHazardPointerContext* self);
410 void gee_hazard_pointer_context_try_release (GeeHazardPointerContext* self);
411 void gee_hazard_pointer_context_release (GeeHazardPointerContext* self);
412 GeeHazardPointerFreeNode* gee_hazard_pointer_free_node_new (void);
413 GeeHazardPointerFreeNode* gee_hazard_pointer_free_node_new (void);
414 gboolean gee_abstract_collection_add (GeeAbstractCollection* self, gconstpointer item);
415 static void gee_hazard_pointer_free_node_instance_init (GeeHazardPointerFreeNode * self);
416 static void gee_hazard_pointer_node_instance_init (GeeHazardPointerNode * self);
417 gboolean gee_hazard_pointer_node_is_active (GeeHazardPointerNode* self);
421 * Checks if the policy is concrete or if it depends on global variables.
423 * @return ``true`` if this policy does not depend on global variables
425 gboolean gee_hazard_pointer_policy_is_concrete (GeeHazardPointerPolicy self) {
426 gboolean result = FALSE;
428 case GEE_HAZARD_POINTER_POLICY_DEFAULT:
429 case GEE_HAZARD_POINTER_POLICY_THREAD_EXIT:
434 case GEE_HAZARD_POINTER_POLICY_TRY_FREE:
435 case GEE_HAZARD_POINTER_POLICY_FREE:
436 case GEE_HAZARD_POINTER_POLICY_TRY_RELEASE:
437 case GEE_HAZARD_POINTER_POLICY_RELEASE:
444 g_assert_not_reached ();
451 * Checks if policy blocks or is lock-free.
452 * Please note that it works on a concrete policy only.
454 * @return ``true`` if the policy may block the thread.
456 gboolean gee_hazard_pointer_policy_is_blocking (GeeHazardPointerPolicy self) {
457 gboolean result = FALSE;
458 gboolean _tmp0_ = FALSE;
459 _tmp0_ = gee_hazard_pointer_policy_is_concrete (self);
460 g_return_val_if_fail (_tmp0_, FALSE);
462 case GEE_HAZARD_POINTER_POLICY_TRY_FREE:
463 case GEE_HAZARD_POINTER_POLICY_TRY_RELEASE:
468 case GEE_HAZARD_POINTER_POLICY_FREE:
469 case GEE_HAZARD_POINTER_POLICY_RELEASE:
476 g_assert_not_reached ();
483 * Checks if policy guarantees freeing all elements.
484 * Please note that it works on a concrete policy only.
486 * @return ``true`` if the policy guarantees freeing all elements.
488 gboolean gee_hazard_pointer_policy_is_safe (GeeHazardPointerPolicy self) {
489 gboolean result = FALSE;
490 gboolean _tmp0_ = FALSE;
491 _tmp0_ = gee_hazard_pointer_policy_is_concrete (self);
492 g_return_val_if_fail (_tmp0_, FALSE);
494 case GEE_HAZARD_POINTER_POLICY_TRY_FREE:
495 case GEE_HAZARD_POINTER_POLICY_TRY_RELEASE:
500 case GEE_HAZARD_POINTER_POLICY_FREE:
501 case GEE_HAZARD_POINTER_POLICY_RELEASE:
508 g_assert_not_reached ();
515 * Finds concrete policy which corresponds to given policy.
517 * @return Policy that corresponds to given policy at given time in given thread.
519 GeeHazardPointerPolicy gee_hazard_pointer_policy_to_concrete (GeeHazardPointerPolicy self) {
520 GeeHazardPointerPolicy result = 0;
522 case GEE_HAZARD_POINTER_POLICY_TRY_FREE:
523 case GEE_HAZARD_POINTER_POLICY_FREE:
524 case GEE_HAZARD_POINTER_POLICY_TRY_RELEASE:
525 case GEE_HAZARD_POINTER_POLICY_RELEASE:
527 GeeHazardPointerPolicy _tmp0_;
528 gboolean _tmp1_ = FALSE;
531 _tmp1_ = gee_hazard_pointer_policy_is_concrete (_tmp0_);
532 g_warn_if_fail (_tmp1_);
535 case GEE_HAZARD_POINTER_POLICY_DEFAULT:
538 GeeHazardPointerPolicy _tmp3_;
539 gboolean _tmp4_ = FALSE;
540 _tmp2_ = g_atomic_int_get ((volatile gint *) (&gee_hazard_pointer__default_policy));
541 result = (GeeHazardPointerPolicy) _tmp2_;
543 _tmp4_ = gee_hazard_pointer_policy_is_concrete (_tmp3_);
544 g_warn_if_fail (_tmp4_);
547 case GEE_HAZARD_POINTER_POLICY_THREAD_EXIT:
550 GeeHazardPointerPolicy _tmp6_;
551 gboolean _tmp7_ = FALSE;
552 _tmp5_ = g_atomic_int_get ((volatile gint *) (&gee_hazard_pointer__thread_exit_policy));
553 result = (GeeHazardPointerPolicy) _tmp5_;
555 _tmp7_ = gee_hazard_pointer_policy_is_concrete (_tmp6_);
556 g_warn_if_fail (_tmp7_);
561 g_assert_not_reached ();
569 * @param to_free List containing elements to free.
570 * @return Non-empty list of not freed elements or ``null`` if all elements have been disposed.
572 GeeArrayList* gee_hazard_pointer_policy_perform (GeeHazardPointerPolicy self, GeeArrayList* to_free) {
573 GeeArrayList* result = NULL;
574 GeeHazardPointerPolicy _tmp0_ = 0;
575 g_return_val_if_fail (to_free != NULL, NULL);
576 _tmp0_ = gee_hazard_pointer_policy_to_concrete (self);
578 case GEE_HAZARD_POINTER_POLICY_TRY_FREE:
580 GeeArrayList* _tmp1_ = NULL;
581 GeeArrayList* _tmp2_;
582 gboolean _tmp3_ = FALSE;
584 _tmp3_ = gee_hazard_pointer_try_free (_tmp2_);
586 GeeArrayList* _tmp4_;
589 _g_object_unref0 (_tmp1_);
592 _g_object_unref0 (_tmp1_);
596 _g_object_unref0 (to_free);
599 case GEE_HAZARD_POINTER_POLICY_FREE:
602 GeeArrayList* _tmp5_;
603 gboolean _tmp6_ = FALSE;
605 _tmp6_ = gee_hazard_pointer_try_free (_tmp5_);
612 _g_object_unref0 (to_free);
615 case GEE_HAZARD_POINTER_POLICY_TRY_RELEASE:
617 gboolean _tmp7_ = FALSE;
618 gee_hazard_pointer_release_policy_ensure_start ();
619 _tmp7_ = g_static_mutex_trylock (&gee_hazard_pointer__queue_mutex);
622 GeeArrayList* _tmp9_;
623 GeeArrayList* _tmp10_;
624 _tmp8_ = gee_hazard_pointer__queue;
628 gee_queue_offer (_tmp8_, _tmp10_);
629 _g_object_unref0 (_tmp10_);
630 g_static_mutex_unlock (&gee_hazard_pointer__queue_mutex);
632 _g_object_unref0 (to_free);
635 GeeArrayList* _tmp11_;
639 _g_object_unref0 (to_free);
643 case GEE_HAZARD_POINTER_POLICY_RELEASE:
646 GeeArrayList* _tmp13_;
647 GeeArrayList* _tmp14_;
648 gee_hazard_pointer_release_policy_ensure_start ();
649 g_static_mutex_lock (&gee_hazard_pointer__queue_mutex);
650 _tmp12_ = gee_hazard_pointer__queue;
654 gee_queue_offer (_tmp12_, _tmp14_);
655 _g_object_unref0 (_tmp14_);
656 g_static_mutex_unlock (&gee_hazard_pointer__queue_mutex);
658 _g_object_unref0 (to_free);
663 g_assert_not_reached ();
666 _g_object_unref0 (to_free);
671 * Policy determines what happens on exit from Context.
673 GType gee_hazard_pointer_policy_get_type (void) {
674 static volatile gsize gee_hazard_pointer_policy_type_id__volatile = 0;
675 if (g_once_init_enter (&gee_hazard_pointer_policy_type_id__volatile)) {
676 static const GEnumValue values[] = {{GEE_HAZARD_POINTER_POLICY_DEFAULT, "GEE_HAZARD_POINTER_POLICY_DEFAULT", "default"}, {GEE_HAZARD_POINTER_POLICY_THREAD_EXIT, "GEE_HAZARD_POINTER_POLICY_THREAD_EXIT", "thread-exit"}, {GEE_HAZARD_POINTER_POLICY_TRY_FREE, "GEE_HAZARD_POINTER_POLICY_TRY_FREE", "try-free"}, {GEE_HAZARD_POINTER_POLICY_FREE, "GEE_HAZARD_POINTER_POLICY_FREE", "free"}, {GEE_HAZARD_POINTER_POLICY_TRY_RELEASE, "GEE_HAZARD_POINTER_POLICY_TRY_RELEASE", "try-release"}, {GEE_HAZARD_POINTER_POLICY_RELEASE, "GEE_HAZARD_POINTER_POLICY_RELEASE", "release"}, {0, NULL, NULL}};
677 GType gee_hazard_pointer_policy_type_id;
678 gee_hazard_pointer_policy_type_id = g_enum_register_static ("GeeHazardPointerPolicy", values);
679 g_once_init_leave (&gee_hazard_pointer_policy_type_id__volatile, gee_hazard_pointer_policy_type_id);
681 return gee_hazard_pointer_policy_type_id__volatile;
685 static gboolean ___lambda33_ (void) {
686 gboolean result = FALSE;
687 GThread* _tmp0_ = NULL;
688 _tmp0_ = g_thread_self ();
689 g_thread_set_priority (_tmp0_, G_THREAD_PRIORITY_LOW);
692 gee_hazard_pointer_release_policy_attempt_free ();
698 static gpointer ____lambda33__gthread_func (gpointer self) {
700 result = ___lambda33_ ();
705 static gboolean ___lambda35_ (void) {
706 gboolean result = FALSE;
707 gee_hazard_pointer_release_policy_attempt_free ();
713 static gboolean ____lambda35__gsource_func (gpointer self) {
715 result = ___lambda35_ ();
720 static void gee_hazard_pointer_release_policy_start (GeeHazardPointerReleasePolicy _self_) {
721 GeeHazardPointerReleasePolicy _tmp0_;
722 GError * _inner_error_ = NULL;
725 case GEE_HAZARD_POINTER_RELEASE_POLICY_HELPER_THREAD:
727 g_thread_create (____lambda33__gthread_func, NULL, FALSE, &_inner_error_);
728 if (_inner_error_ != NULL) {
729 g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
730 g_clear_error (&_inner_error_);
735 case GEE_HAZARD_POINTER_RELEASE_POLICY_MAIN_LOOP:
737 g_idle_add_full (G_PRIORITY_LOW, ____lambda35__gsource_func, NULL, NULL);
742 g_assert_not_reached ();
749 * Ensures that helper methods are started.
751 inline void gee_hazard_pointer_release_policy_ensure_start (void) {
755 gboolean _tmp2_ = FALSE;
756 _tmp0_ = g_atomic_int_get ((volatile gint *) (&gee_hazard_pointer_release_policy));
759 if ((_tmp1_ & (1 << ((sizeof (gint) * 8) - 1))) != 0) {
762 _tmp2_ = g_static_mutex_trylock (&gee_hazard_pointer__queue_mutex);
766 _tmp3_ = g_atomic_int_get ((volatile gint *) (&gee_hazard_pointer_release_policy));
769 if ((_tmp4_ & (1 << ((sizeof (gint) * 8) - 1))) == 0) {
770 GeeLinkedList* _tmp5_;
773 _tmp5_ = gee_linked_list_new (GEE_TYPE_ARRAY_LIST, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL, NULL, NULL);
774 _g_object_unref0 (gee_hazard_pointer__queue);
775 gee_hazard_pointer__queue = (GeeQueue*) _tmp5_;
776 _tmp6_ = g_atomic_int_exchange_and_add ((volatile gint *) (&gee_hazard_pointer_release_policy), (gint) (1 << ((sizeof (gint) * 8) - 1)));
779 gee_hazard_pointer_release_policy_start ((GeeHazardPointerReleasePolicy) _tmp7_);
781 g_static_mutex_unlock (&gee_hazard_pointer__queue_mutex);
786 static gboolean ___lambda34_ (GeeArrayList* x) {
787 gboolean result = FALSE;
788 GeeArrayList* _tmp0_;
789 GeeArrayList* _tmp1_;
790 g_return_val_if_fail (x != NULL, FALSE);
791 _tmp0_ = gee_hazard_pointer__global_to_free;
793 gee_array_list_add_all (_tmp0_, (GeeCollection*) _tmp1_);
795 _g_object_unref0 (x);
800 static gboolean ____lambda34__gee_forall_func (gpointer g, gpointer self) {
802 result = ___lambda34_ (g);
807 static inline void gee_hazard_pointer_release_policy_attempt_free (void) {
808 gboolean _tmp0_ = FALSE;
809 GeeArrayList* _tmp5_;
810 _tmp0_ = g_static_mutex_trylock (&gee_hazard_pointer__queue_mutex);
812 GeeArrayList* _tmp1_;
815 GeeCollection* _tmp3_;
816 GeeCollection* _tmp4_;
817 _tmp1_ = gee_array_list_new (GEE_TYPE_ARRAY_LIST, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL, NULL, NULL);
818 temp = (GeeCollection*) _tmp1_;
819 _tmp2_ = gee_hazard_pointer__queue;
821 gee_queue_drain (_tmp2_, _tmp3_, -1);
822 g_static_mutex_unlock (&gee_hazard_pointer__queue_mutex);
824 gee_traversable_foreach ((GeeTraversable*) _tmp4_, ____lambda34__gee_forall_func, NULL);
825 _g_object_unref0 (temp);
827 _tmp5_ = gee_hazard_pointer__global_to_free;
828 gee_hazard_pointer_try_free (_tmp5_);
833 * Release policy determines what happens with object freed by Policy.TRY_RELEASE
834 * and Policy.RELEASE.
836 GType gee_hazard_pointer_release_policy_get_type (void) {
837 static volatile gsize gee_hazard_pointer_release_policy_type_id__volatile = 0;
838 if (g_once_init_enter (&gee_hazard_pointer_release_policy_type_id__volatile)) {
839 static const GEnumValue values[] = {{GEE_HAZARD_POINTER_RELEASE_POLICY_HELPER_THREAD, "GEE_HAZARD_POINTER_RELEASE_POLICY_HELPER_THREAD", "helper-thread"}, {GEE_HAZARD_POINTER_RELEASE_POLICY_MAIN_LOOP, "GEE_HAZARD_POINTER_RELEASE_POLICY_MAIN_LOOP", "main-loop"}, {0, NULL, NULL}};
840 GType gee_hazard_pointer_release_policy_type_id;
841 gee_hazard_pointer_release_policy_type_id = g_enum_register_static ("GeeHazardPointerReleasePolicy", values);
842 g_once_init_leave (&gee_hazard_pointer_release_policy_type_id__volatile, gee_hazard_pointer_release_policy_type_id);
844 return gee_hazard_pointer_release_policy_type_id__volatile;
849 * Creates a hazard pointer for a pointer.
851 * @param ptr Protected pointer
853 GeeHazardPointer* gee_hazard_pointer_new (gconstpointer* ptr) {
854 GeeHazardPointer* self;
855 GeeHazardPointerNode* _tmp0_ = NULL;
856 GeeHazardPointerNode* _tmp1_;
857 gconstpointer* _tmp2_;
858 self = g_slice_new0 (GeeHazardPointer);
859 gee_hazard_pointer_instance_init (self);
860 _tmp0_ = gee_hazard_pointer_acquire ();
861 self->_node = _tmp0_;
862 _tmp1_ = self->_node;
864 gee_hazard_pointer_node_set (_tmp1_, (void*) _tmp2_);
870 * Create a hazard pointer from Node.
872 GeeHazardPointer* gee_hazard_pointer_new_from_node (GeeHazardPointerNode* node) {
873 GeeHazardPointer* self;
874 GeeHazardPointerNode* _tmp0_;
875 g_return_val_if_fail (node != NULL, NULL);
876 self = g_slice_new0 (GeeHazardPointer);
877 gee_hazard_pointer_instance_init (self);
879 self->_node = _tmp0_;
885 * Gets hazard pointer from atomic pointer safely.
887 * @param aptr Atomic pointer.
888 * @param mask Mask of bits.
889 * @param mask_out Result of mask.
890 * @return Hazard pointer containing the element.
892 GeeHazardPointer* gee_hazard_pointer_get_hazard_pointer (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, gconstpointer** aptr, gsize mask, gsize* mask_out) {
893 gsize _vala_mask_out = 0UL;
894 GeeHazardPointer* result = NULL;
895 GeeHazardPointerNode* _tmp0_ = NULL;
896 GeeHazardPointerNode* node;
900 _tmp0_ = gee_hazard_pointer_acquire ();
904 _vala_mask_out = (gsize) 0;
910 gconstpointer** _tmp6_;
916 GeeHazardPointerNode* _tmp12_;
921 gconstpointer** _tmp4_;
925 _tmp5_ = g_atomic_pointer_get ((volatile gpointer *) ((void**) _tmp4_));
926 if (!(_tmp3_ != _tmp5_)) {
932 _tmp7_ = g_atomic_pointer_get ((volatile gpointer *) ((void**) _tmp6_));
936 ptr = (void*) (((gsize) _tmp8_) & (~_tmp9_));
939 _vala_mask_out = ((gsize) _tmp10_) & _tmp11_;
942 gee_hazard_pointer_node_set (_tmp12_, _tmp13_);
946 if (_tmp14_ != NULL) {
947 GeeHazardPointerNode* _tmp15_;
948 GeeHazardPointer* _tmp16_;
950 _tmp16_ = gee_hazard_pointer_new_from_node (_tmp15_);
953 *mask_out = _vala_mask_out;
957 GeeHazardPointerNode* _tmp17_;
959 gee_hazard_pointer_node_release (_tmp17_);
962 *mask_out = _vala_mask_out;
967 *mask_out = _vala_mask_out;
973 * Copy an object from atomic pointer.
975 * @param aptr Atomic pointer.
976 * @param mask Mask of flags.
977 * @param mask_out Result of mask.
978 * @return A copy of object from atomic pointer.
980 gpointer gee_hazard_pointer_get_pointer (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, gconstpointer** aptr, gsize mask, gsize* mask_out) {
981 gsize _vala_mask_out = 0UL;
982 gpointer result = NULL;
983 GeeHazardPointerNode* _tmp0_ = NULL;
984 GeeHazardPointerNode* node;
990 GeeHazardPointerNode* _tmp16_;
991 _tmp0_ = gee_hazard_pointer_acquire ();
995 _vala_mask_out = (gsize) 0;
1001 gconstpointer** _tmp6_;
1002 void* _tmp7_ = NULL;
1007 GeeHazardPointerNode* _tmp12_;
1012 gconstpointer** _tmp4_;
1013 void* _tmp5_ = NULL;
1016 _tmp5_ = g_atomic_pointer_get ((volatile gpointer *) ((void**) _tmp4_));
1017 if (!(_tmp3_ != _tmp5_)) {
1023 _tmp7_ = g_atomic_pointer_get ((volatile gpointer *) ((void**) _tmp6_));
1027 ptr = (void*) (((gsize) _tmp8_) & (~_tmp9_));
1030 _vala_mask_out = ((gsize) _tmp10_) & _tmp11_;
1033 gee_hazard_pointer_node_set (_tmp12_, _tmp13_);
1037 _tmp15_ = ((((gconstpointer*) _tmp14_) != NULL) && (g_dup_func != NULL)) ? g_dup_func ((gpointer) ((gconstpointer*) _tmp14_)) : ((gpointer) ((gconstpointer*) _tmp14_));
1040 gee_hazard_pointer_node_release (_tmp16_);
1043 *mask_out = _vala_mask_out;
1050 * Exchange objects safly.
1052 * @param aptr Atomic pointer.
1053 * @param new_ptr New value
1054 * @param mask Mask of flags.
1055 * @param new_mask New mask.
1056 * @param old_mask Previous mask mask.
1057 * @return Hazard pointer containing old value.
1059 GeeHazardPointer* gee_hazard_pointer_exchange_hazard_pointer (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, gconstpointer** aptr, gpointer new_ptr, gsize mask, gsize new_mask, gsize* old_mask) {
1060 gsize _vala_old_mask = 0UL;
1061 GeeHazardPointer* result = NULL;
1062 GeeHazardPointerNode* new_node;
1063 gconstpointer _tmp0_;
1068 GeeHazardPointerNode* _tmp7_ = NULL;
1069 GeeHazardPointerNode* node;
1072 GeeHazardPointerNode* _tmp22_;
1076 if (_tmp0_ != NULL) {
1077 GeeHazardPointerNode* _tmp1_ = NULL;
1078 GeeHazardPointerNode* _tmp2_;
1079 gconstpointer _tmp3_;
1080 _tmp1_ = gee_hazard_pointer_acquire ();
1084 gee_hazard_pointer_node_set (_tmp2_, _tmp3_);
1086 _vala_old_mask = (gsize) 0;
1091 new_rptr = (void*) (((gsize) _tmp4_) | (_tmp5_ & _tmp6_));
1092 _tmp7_ = gee_hazard_pointer_acquire ();
1101 gconstpointer** _tmp14_;
1102 void* _tmp15_ = NULL;
1107 GeeHazardPointerNode* _tmp20_;
1111 gconstpointer** _tmp10_;
1114 gboolean _tmp13_ = FALSE;
1118 _tmp13_ = g_atomic_pointer_compare_and_exchange ((volatile gpointer *) ((void**) _tmp10_), _tmp11_, _tmp12_);
1125 _tmp15_ = g_atomic_pointer_get ((volatile gpointer *) ((void**) _tmp14_));
1129 ptr = (void*) (((gsize) _tmp16_) & (~_tmp17_));
1132 _vala_old_mask = ((gsize) _tmp18_) & _tmp19_;
1135 gee_hazard_pointer_node_set (_tmp20_, _tmp21_);
1139 if (_tmp22_ != NULL) {
1140 GeeHazardPointerNode* _tmp23_;
1142 gee_hazard_pointer_node_release (_tmp23_);
1145 if (_tmp24_ != NULL) {
1146 GeeHazardPointerNode* _tmp25_;
1147 GeeHazardPointer* _tmp26_;
1149 _tmp26_ = gee_hazard_pointer_new_from_node (_tmp25_);
1151 _g_destroy_func0 (new_ptr);
1153 *old_mask = _vala_old_mask;
1157 GeeHazardPointerNode* _tmp27_;
1159 gee_hazard_pointer_node_release (_tmp27_);
1161 _g_destroy_func0 (new_ptr);
1163 *old_mask = _vala_old_mask;
1167 _g_destroy_func0 (new_ptr);
1169 *old_mask = _vala_old_mask;
1175 * Sets object safely
1177 * @param aptr Atomic pointer.
1178 * @param new_ptr New value
1179 * @param mask Mask of flags.
1180 * @param new_mask New mask.
1182 void gee_hazard_pointer_set_pointer (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, gconstpointer** aptr, gpointer new_ptr, gsize mask, gsize new_mask) {
1183 gconstpointer** _tmp0_;
1184 gconstpointer _tmp1_;
1188 GeeHazardPointer* _tmp5_ = NULL;
1189 GeeHazardPointer* ptr;
1190 GeeHazardPointer* _tmp6_;
1193 _tmp2_ = ((_tmp1_ != NULL) && (g_dup_func != NULL)) ? g_dup_func ((gpointer) _tmp1_) : ((gpointer) _tmp1_);
1196 _tmp5_ = gee_hazard_pointer_exchange_hazard_pointer (g_type, (GBoxedCopyFunc) g_dup_func, g_destroy_func, _tmp0_, _tmp2_, _tmp3_, _tmp4_, NULL);
1199 if (_tmp6_ != NULL) {
1200 void* _tmp7_ = NULL;
1201 GDestroyNotify _tmp8_ = NULL;
1202 GeeHazardPointerDestroyNotify _tmp9_ = NULL;
1203 GeeHazardPointerDestroyNotify notify;
1204 void* notify_target;
1205 GDestroyNotify notify_target_destroy_notify;
1206 GeeHazardPointer* _tmp10_;
1207 GeeHazardPointerDestroyNotify _tmp11_;
1208 void* _tmp11__target;
1209 GDestroyNotify _tmp11__target_destroy_notify;
1210 _tmp9_ = gee_hazard_pointer_get_destroy_notify (g_type, (GBoxedCopyFunc) g_dup_func, g_destroy_func, &_tmp7_, &_tmp8_);
1212 notify_target = _tmp7_;
1213 notify_target_destroy_notify = _tmp8_;
1216 _tmp11__target = notify_target;
1217 _tmp11__target_destroy_notify = notify_target_destroy_notify;
1218 notify_target_destroy_notify = NULL;
1219 gee_hazard_pointer_release (_tmp10_, _tmp11_, _tmp11__target, _tmp11__target_destroy_notify);
1220 (notify_target_destroy_notify == NULL) ? NULL : (notify_target_destroy_notify (notify_target), NULL);
1222 notify_target = NULL;
1223 notify_target_destroy_notify = NULL;
1225 _gee_hazard_pointer_free0 (ptr);
1226 _g_destroy_func0 (new_ptr);
1231 * Exchange objects safly.
1233 * @param aptr Atomic pointer.
1234 * @param new_ptr New value
1235 * @param mask Mask of flags.
1236 * @param new_mask New mask.
1237 * @param old_mask Previous mask mask.
1238 * @return Value that was previously stored.
1240 gpointer gee_hazard_pointer_exchange_pointer (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, gconstpointer** aptr, gpointer new_ptr, gsize mask, gsize new_mask, gsize* old_mask) {
1241 gsize _vala_old_mask = 0UL;
1242 gpointer result = NULL;
1243 gconstpointer** _tmp0_;
1244 gconstpointer _tmp1_;
1249 GeeHazardPointer* _tmp6_ = NULL;
1250 GeeHazardPointer* ptr;
1251 gconstpointer _tmp7_ = NULL;
1252 GeeHazardPointer* _tmp8_;
1253 gconstpointer _tmp11_;
1258 _tmp2_ = ((_tmp1_ != NULL) && (g_dup_func != NULL)) ? g_dup_func ((gpointer) _tmp1_) : ((gpointer) _tmp1_);
1261 _tmp6_ = gee_hazard_pointer_exchange_hazard_pointer (g_type, (GBoxedCopyFunc) g_dup_func, g_destroy_func, _tmp0_, _tmp2_, _tmp3_, _tmp4_, &_tmp5_);
1262 _vala_old_mask = _tmp5_;
1265 if (_tmp8_ != NULL) {
1266 GeeHazardPointer* _tmp9_;
1267 gconstpointer _tmp10_ = NULL;
1269 _tmp10_ = gee_hazard_pointer_get (_tmp9_, FALSE);
1275 _tmp12_ = ((_tmp11_ != NULL) && (g_dup_func != NULL)) ? g_dup_func ((gpointer) _tmp11_) : ((gpointer) _tmp11_);
1278 _gee_hazard_pointer_free0 (ptr);
1279 _g_destroy_func0 (new_ptr);
1281 *old_mask = _vala_old_mask;
1288 * Compares and exchanges objects.
1290 * @param aptr Atomic pointer.
1291 * @param old_ptr Old pointer.
1292 * @param _new_ptr New value.
1293 * @param old_mask Old mask.
1294 * @param new_mask New mask.
1295 * @return Value that was previously stored.
1297 gboolean gee_hazard_pointer_compare_and_exchange_pointer (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, gconstpointer** aptr, gconstpointer old_ptr, gpointer _new_ptr, gsize mask, gsize old_mask, gsize new_mask) {
1298 gboolean result = FALSE;
1300 gconstpointer* new_ptr;
1301 gconstpointer* _tmp1_;
1305 gconstpointer _tmp4_;
1309 gconstpointer** _tmp7_;
1312 gboolean _tmp10_ = FALSE;
1321 new_rptr = (void*) (((gsize) _tmp1_) | (_tmp2_ & _tmp3_));
1325 old_rptr = (void*) (((gsize) _tmp4_) | (_tmp5_ & _tmp6_));
1329 _tmp10_ = g_atomic_pointer_compare_and_exchange ((volatile gpointer *) ((void**) _tmp7_), _tmp8_, _tmp9_);
1333 void* _tmp12_ = NULL;
1334 GDestroyNotify _tmp13_ = NULL;
1335 GeeHazardPointerDestroyNotify _tmp14_ = NULL;
1336 GeeHazardPointerDestroyNotify notify;
1337 void* notify_target;
1338 GDestroyNotify notify_target_destroy_notify;
1339 gconstpointer _tmp15_;
1340 _tmp14_ = gee_hazard_pointer_get_destroy_notify (g_type, (GBoxedCopyFunc) g_dup_func, g_destroy_func, &_tmp12_, &_tmp13_);
1342 notify_target = _tmp12_;
1343 notify_target_destroy_notify = _tmp13_;
1345 if (_tmp15_ != NULL) {
1346 GeeHazardPointerContext* _tmp16_ = NULL;
1347 gconstpointer _tmp17_;
1348 GeeHazardPointerDestroyNotify _tmp18_;
1349 void* _tmp18__target;
1350 GDestroyNotify _tmp18__target_destroy_notify;
1351 _tmp16_ = gee_hazard_pointer_context_get_current_context ();
1354 _tmp18__target = notify_target;
1355 _tmp18__target_destroy_notify = notify_target_destroy_notify;
1356 notify_target_destroy_notify = NULL;
1357 gee_hazard_pointer_context_release_ptr (_tmp16_, _tmp17_, _tmp18_, _tmp18__target, _tmp18__target_destroy_notify);
1359 (notify_target_destroy_notify == NULL) ? NULL : (notify_target_destroy_notify (notify_target), NULL);
1361 notify_target = NULL;
1362 notify_target_destroy_notify = NULL;
1364 gconstpointer* _tmp19_;
1366 if (_tmp19_ != NULL) {
1367 gconstpointer* _tmp20_;
1370 _g_destroy_func0 (_new_ptr);
1375 _g_destroy_func0 (_new_ptr);
1381 * Gets the pointer hold by hazard pointer.
1383 * @param other_thread Have to be set to ``true`` if accessed from thread that did not create this thread.
1384 * @return The value hold by pointer.
1386 inline gconstpointer gee_hazard_pointer_get (GeeHazardPointer* self, gboolean other_thread) {
1387 gconstpointer result = NULL;
1388 GeeHazardPointerNode* _tmp0_;
1390 void* _tmp2_ = NULL;
1391 g_return_val_if_fail (self != NULL, NULL);
1392 _tmp0_ = self->_node;
1393 _tmp1_ = other_thread;
1394 _tmp2_ = gee_hazard_pointer_node_get (_tmp0_, _tmp1_);
1403 * @param notify method freeing object
1405 void gee_hazard_pointer_release (GeeHazardPointer* self, GeeHazardPointerDestroyNotify notify, void* notify_target, GDestroyNotify notify_target_destroy_notify) {
1406 GeeHazardPointerNode* _tmp0_;
1407 void* _tmp1_ = NULL;
1409 GeeHazardPointerNode* _tmp2_;
1410 gconstpointer _tmp3_;
1411 g_return_if_fail (self != NULL);
1412 _tmp0_ = self->_node;
1413 _tmp1_ = gee_hazard_pointer_node_get (_tmp0_, FALSE);
1415 _tmp2_ = self->_node;
1416 gee_hazard_pointer_node_set (_tmp2_, NULL);
1418 if (_tmp3_ != NULL) {
1419 GeeHazardPointerContext* _tmp4_ = NULL;
1420 gconstpointer _tmp5_;
1421 GeeHazardPointerDestroyNotify _tmp6_;
1422 void* _tmp6__target;
1423 GDestroyNotify _tmp6__target_destroy_notify;
1424 _tmp4_ = gee_hazard_pointer_context_get_current_context ();
1427 _tmp6__target = notify_target;
1428 _tmp6__target_destroy_notify = notify_target_destroy_notify;
1429 notify_target_destroy_notify = NULL;
1430 gee_hazard_pointer_context_release_ptr (_tmp4_, _tmp5_, _tmp6_, _tmp6__target, _tmp6__target_destroy_notify);
1432 (notify_target_destroy_notify == NULL) ? NULL : (notify_target_destroy_notify (notify_target), NULL);
1434 notify_target = NULL;
1435 notify_target_destroy_notify = NULL;
1440 * Sets default policy (i.e. default policy for user-created contexts).
1441 * The policy must be concrete and should not be blocking.
1443 * @param policy New default policy.
1445 void gee_hazard_pointer_set_default_policy (GeeHazardPointerPolicy policy) {
1446 GeeHazardPointerPolicy _tmp0_;
1447 gboolean _tmp1_ = FALSE;
1448 GeeHazardPointerPolicy _tmp2_;
1449 gboolean _tmp3_ = FALSE;
1450 GeeHazardPointerPolicy _tmp4_;
1452 _tmp1_ = gee_hazard_pointer_policy_is_concrete (_tmp0_);
1453 g_return_if_fail (_tmp1_);
1455 _tmp3_ = gee_hazard_pointer_policy_is_blocking (_tmp2_);
1457 g_warning ("hazardpointer.vala:250: Setting blocking defautl Gee.HazardPointer.Pol" \
1458 "icy (there may be a deadlock).\n");
1461 g_atomic_int_set ((volatile gint *) (&gee_hazard_pointer__default_policy), (gint) _tmp4_);
1466 * Sets thread exit policy (i.e. default policy for the top-most Context).
1467 * The policy must be concrete and should not be unsafe.
1469 * @param policy New thread policy.
1471 void gee_hazard_pointer_set_thread_exit_policy (GeeHazardPointerPolicy policy) {
1472 GeeHazardPointerPolicy _tmp0_;
1473 gboolean _tmp1_ = FALSE;
1474 GeeHazardPointerPolicy _tmp2_;
1475 gboolean _tmp3_ = FALSE;
1476 GeeHazardPointerPolicy _tmp4_;
1478 _tmp1_ = gee_hazard_pointer_policy_is_concrete (_tmp0_);
1479 g_return_if_fail (_tmp1_);
1481 _tmp3_ = gee_hazard_pointer_policy_is_safe (_tmp2_);
1483 g_warning ("hazardpointer.vala:262: Setting unsafe globale thread-exit Gee.HazardP" \
1484 "ointer.Policy (there may be a memory leak).\n");
1487 g_atomic_int_set ((volatile gint *) (&gee_hazard_pointer__thread_exit_policy), (gint) _tmp4_);
1492 * Sets release (i.e. how exactly the released objects arefreed).
1494 * The method can be only set before any objects is released and is not thread-safe.
1496 * @param policy New release policy.
1498 gboolean gee_hazard_pointer_set_release_policy (GeeHazardPointerReleasePolicy policy) {
1499 gboolean result = FALSE;
1504 GeeHazardPointerReleasePolicy _tmp3_;
1505 gboolean _tmp4_ = FALSE;
1506 _tmp0_ = g_atomic_int_get ((volatile gint *) (&gee_hazard_pointer_release_policy));
1507 old_policy = _tmp0_;
1508 _tmp1_ = old_policy;
1509 if ((_tmp1_ & ((sizeof (gint) * 8) - 1)) != 0) {
1510 g_critical ("hazardpointer.vala:276: Attempt to change the policy of running helper" \
1515 _tmp2_ = old_policy;
1517 _tmp4_ = g_atomic_int_compare_and_exchange ((volatile gint *) (&gee_hazard_pointer_release_policy), _tmp2_, (gint) _tmp3_);
1519 g_critical ("hazardpointer.vala:280: Concurrent access to release policy detected. " \
1530 * Gets a new hazard pointer node.
1532 * @return new hazard pointer node.
1534 inline GeeHazardPointerNode* gee_hazard_pointer_acquire (void) {
1535 GeeHazardPointerNode* result = NULL;
1536 GeeHazardPointerNode* _tmp9_;
1537 GeeHazardPointerNode* node;
1538 GeeHazardPointerNode* old_head;
1539 GeeHazardPointerNode* _tmp18_;
1541 GeeHazardPointerNode* _tmp0_ = NULL;
1542 GeeHazardPointerNode* curr;
1543 _tmp0_ = gee_hazard_pointer_get_head ();
1550 GeeHazardPointerNode* _tmp5_;
1551 GeeHazardPointerNode* _tmp6_;
1552 gboolean _tmp7_ = FALSE;
1555 GeeHazardPointerNode* _tmp3_;
1556 GeeHazardPointerNode* _tmp4_ = NULL;
1558 _tmp4_ = gee_hazard_pointer_node_get_next (_tmp3_);
1563 if (!(_tmp5_ != NULL)) {
1567 _tmp7_ = gee_hazard_pointer_node_activate (_tmp6_);
1569 GeeHazardPointerNode* _tmp8_;
1577 _tmp9_ = gee_hazard_pointer_node_new ();
1585 GeeHazardPointerNode* _tmp15_;
1586 void* _tmp16_ = NULL;
1587 GeeHazardPointerNode* _tmp17_;
1590 GeeHazardPointerNode* _tmp12_;
1591 GeeHazardPointerNode* _tmp13_;
1592 gboolean _tmp14_ = FALSE;
1595 _tmp14_ = g_atomic_pointer_compare_and_exchange ((volatile gpointer *) (&gee_hazard_pointer__head), _tmp12_, _tmp13_);
1602 _tmp16_ = g_atomic_pointer_get ((volatile gpointer *) (&gee_hazard_pointer__head));
1603 old_head = (GeeHazardPointerNode*) _tmp16_;
1605 gee_hazard_pointer_node_set_next (_tmp15_, _tmp17_);
1615 * Tries to free from list.
1617 * @return ``true`` if list is empty.
1619 gboolean gee_hazard_pointer_try_free (GeeArrayList* to_free) {
1620 gboolean result = FALSE;
1622 GeeCollection* used;
1623 GeeArrayList* _tmp45_;
1626 g_return_val_if_fail (to_free != NULL, FALSE);
1627 _tmp0_ = gee_hash_set_new (G_TYPE_POINTER, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
1628 used = (GeeCollection*) _tmp0_;
1630 GeeHazardPointerNode* _tmp1_ = NULL;
1631 GeeHazardPointerNode* current;
1632 _tmp1_ = gee_hazard_pointer_get_head ();
1639 GeeHazardPointerNode* _tmp6_;
1640 GeeCollection* _tmp7_;
1641 GeeHazardPointerNode* _tmp8_;
1642 void* _tmp9_ = NULL;
1645 GeeHazardPointerNode* _tmp4_;
1646 GeeHazardPointerNode* _tmp5_ = NULL;
1648 _tmp5_ = gee_hazard_pointer_node_get_next (_tmp4_);
1653 if (!(_tmp6_ != NULL)) {
1658 _tmp9_ = gee_hazard_pointer_node_get (_tmp8_, TRUE);
1659 gee_collection_add (_tmp7_, _tmp9_);
1672 GeeArrayList* _tmp13_;
1675 GeeArrayList* _tmp16_;
1677 gpointer _tmp18_ = NULL;
1678 GeeHazardPointerFreeNode* current;
1679 GeeCollection* _tmp19_;
1680 GeeHazardPointerFreeNode* _tmp20_;
1682 gboolean _tmp22_ = FALSE;
1689 _tmp14_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp13_);
1691 if (!(_tmp12_ < _tmp15_)) {
1696 _tmp18_ = gee_abstract_list_get ((GeeAbstractList*) _tmp16_, _tmp17_);
1700 _tmp21_ = _tmp20_->pointer;
1701 _tmp22_ = gee_collection_contains (_tmp19_, _tmp21_);
1707 GeeArrayList* _tmp24_;
1708 GeeArrayList* _tmp25_;
1711 gpointer _tmp28_ = NULL;
1712 GeeHazardPointerFreeNode* cur;
1714 GeeArrayList* _tmp30_;
1717 GeeHazardPointerFreeNode* _tmp40_;
1718 GeeHazardPointerDestroyNotify _tmp41_;
1719 void* _tmp41__target;
1720 GeeHazardPointerFreeNode* _tmp42_;
1722 GeeHazardPointerFreeNode* _tmp44_;
1725 _tmp26_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp25_);
1727 _tmp28_ = gee_abstract_list_remove_at ((GeeAbstractList*) _tmp24_, _tmp27_ - 1);
1731 _tmp31_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp30_);
1733 if (_tmp29_ != _tmp32_) {
1734 GeeArrayList* _tmp33_;
1736 gpointer _tmp35_ = NULL;
1737 GeeHazardPointerFreeNode* temp;
1738 GeeArrayList* _tmp36_;
1740 GeeHazardPointerFreeNode* _tmp38_;
1741 GeeHazardPointerFreeNode* _tmp39_;
1744 _tmp35_ = gee_abstract_list_get ((GeeAbstractList*) _tmp33_, _tmp34_);
1749 gee_abstract_list_set ((GeeAbstractList*) _tmp36_, _tmp37_, _tmp38_);
1754 _tmp41_ = _tmp40_->destroy_notify;
1755 _tmp41__target = _tmp40_->destroy_notify_target;
1757 _tmp43_ = _tmp42_->pointer;
1758 _tmp41_ (_tmp43_, _tmp41__target);
1760 gee_hazard_pointer_free_node_free (_tmp44_);
1766 _tmp46_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp45_);
1768 result = _tmp47_ > 0;
1769 _g_object_unref0 (used);
1775 * Gets head of hazard pointers.
1776 * @return Hazard pointer head.
1778 GeeHazardPointerNode* gee_hazard_pointer_get_head (void) {
1779 GeeHazardPointerNode* result = NULL;
1780 void* _tmp0_ = NULL;
1781 _tmp0_ = g_atomic_pointer_get ((volatile gpointer *) (&gee_hazard_pointer__head));
1782 result = (GeeHazardPointerNode*) _tmp0_;
1787 static Block5Data* block5_data_ref (Block5Data* _data5_) {
1788 g_atomic_int_inc (&_data5_->_ref_count_);
1793 static void block5_data_unref (void * _userdata_) {
1794 Block5Data* _data5_;
1795 _data5_ = (Block5Data*) _userdata_;
1796 if (g_atomic_int_dec_and_test (&_data5_->_ref_count_)) {
1798 GBoxedCopyFunc g_dup_func;
1799 GDestroyNotify g_destroy_func;
1800 g_type = _data5_->g_type;
1801 g_dup_func = _data5_->g_dup_func;
1802 g_destroy_func = _data5_->g_destroy_func;
1803 g_slice_free (Block5Data, _data5_);
1808 static void __lambda36_ (Block5Data* _data5_, void* ptr) {
1810 GBoxedCopyFunc g_dup_func;
1811 GDestroyNotify g_destroy_func;
1813 gconstpointer* gptr;
1814 gconstpointer* _tmp1_;
1816 g_type = _data5_->g_type;
1817 g_dup_func = _data5_->g_dup_func;
1818 g_destroy_func = _data5_->g_destroy_func;
1824 _g_destroy_func0 (obj);
1826 _g_destroy_func0 (obj);
1830 static void ___lambda36__gee_hazard_pointer_destroy_notify (void* ptr, gpointer self) {
1831 __lambda36_ (self, ptr);
1835 GeeHazardPointerDestroyNotify gee_hazard_pointer_get_destroy_notify (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, void** result_target, GDestroyNotify* result_target_destroy_notify) {
1836 GeeHazardPointerDestroyNotify result = NULL;
1837 Block5Data* _data5_;
1838 GeeHazardPointerDestroyNotify _tmp0_;
1839 void* _tmp0__target;
1840 GDestroyNotify _tmp0__target_destroy_notify;
1841 _data5_ = g_slice_new0 (Block5Data);
1842 _data5_->_ref_count_ = 1;
1843 _data5_->g_type = g_type;
1844 _data5_->g_dup_func = g_dup_func;
1845 _data5_->g_destroy_func = g_destroy_func;
1846 _tmp0_ = ___lambda36__gee_hazard_pointer_destroy_notify;
1847 _tmp0__target = block5_data_ref (_data5_);
1848 _tmp0__target_destroy_notify = block5_data_unref;
1849 *result_target = _tmp0__target;
1850 *result_target_destroy_notify = _tmp0__target_destroy_notify;
1852 block5_data_unref (_data5_);
1858 static GeeHazardPointerPolicy* _gee_hazard_pointer_policy_dup (GeeHazardPointerPolicy* self) {
1859 GeeHazardPointerPolicy* dup;
1860 dup = g_new0 (GeeHazardPointerPolicy, 1);
1861 memcpy (dup, self, sizeof (GeeHazardPointerPolicy));
1866 static gpointer __gee_hazard_pointer_policy_dup0 (gpointer self) {
1867 return self ? _gee_hazard_pointer_policy_dup (self) : NULL;
1871 GeeHazardPointerContext* gee_hazard_pointer_context_new (GeeHazardPointerPolicy* policy) {
1872 GeeHazardPointerContext* self;
1873 GeeArrayList* _tmp0_;
1874 void* _tmp1_ = NULL;
1875 GeeHazardPointerPolicy* _tmp2_;
1876 self = g_slice_new0 (GeeHazardPointerContext);
1877 gee_hazard_pointer_context_instance_init (self);
1878 _tmp0_ = gee_array_list_new (G_TYPE_POINTER, NULL, NULL, NULL, NULL, NULL);
1879 _g_object_unref0 (self->_to_free);
1880 self->_to_free = _tmp0_;
1881 _tmp1_ = g_static_private_get (&gee_hazard_pointer_context__current_context);
1882 self->_parent = _tmp1_;
1883 g_static_private_set (&gee_hazard_pointer_context__current_context, self, NULL);
1885 if (_tmp2_ == NULL) {
1886 GeeHazardPointerContext* _tmp3_;
1887 _tmp3_ = self->_parent;
1888 if (_tmp3_ == NULL) {
1890 GeeHazardPointerPolicy _tmp5_;
1891 GeeHazardPointerPolicy* _tmp6_;
1892 _tmp4_ = g_atomic_int_get ((volatile gint *) (&gee_hazard_pointer__thread_exit_policy));
1893 _tmp5_ = (GeeHazardPointerPolicy) _tmp4_;
1894 _tmp6_ = __gee_hazard_pointer_policy_dup0 (&_tmp5_);
1895 _g_free0 (self->_policy);
1896 self->_policy = _tmp6_;
1899 GeeHazardPointerPolicy _tmp8_;
1900 GeeHazardPointerPolicy* _tmp9_;
1901 _tmp7_ = g_atomic_int_get ((volatile gint *) (&gee_hazard_pointer__default_policy));
1902 _tmp8_ = (GeeHazardPointerPolicy) _tmp7_;
1903 _tmp9_ = __gee_hazard_pointer_policy_dup0 (&_tmp8_);
1904 _g_free0 (self->_policy);
1905 self->_policy = _tmp9_;
1908 GeeHazardPointerPolicy* _tmp10_;
1909 GeeHazardPointerPolicy _tmp11_ = 0;
1910 GeeHazardPointerPolicy* _tmp12_;
1912 _tmp11_ = gee_hazard_pointer_policy_to_concrete (*_tmp10_);
1913 _tmp12_ = __gee_hazard_pointer_policy_dup0 (&_tmp11_);
1914 _g_free0 (self->_policy);
1915 self->_policy = _tmp12_;
1922 * Tries to free all freed pointer in current context.
1924 void gee_hazard_pointer_context_try_free (GeeHazardPointerContext* self) {
1925 GeeArrayList* _tmp0_;
1926 g_return_if_fail (self != NULL);
1927 _tmp0_ = self->_to_free;
1928 gee_hazard_pointer_try_free (_tmp0_);
1933 * Ensure that whole context is freed. Plase note that it might block.
1935 void gee_hazard_pointer_context_free_all (GeeHazardPointerContext* self) {
1936 g_return_if_fail (self != NULL);
1938 GeeArrayList* _tmp0_;
1939 gboolean _tmp1_ = FALSE;
1940 _tmp0_ = self->_to_free;
1941 _tmp1_ = gee_hazard_pointer_try_free (_tmp0_);
1951 * Tries to push the current context to releaser.
1953 void gee_hazard_pointer_context_try_release (GeeHazardPointerContext* self) {
1954 gboolean _tmp0_ = FALSE;
1955 g_return_if_fail (self != NULL);
1956 _tmp0_ = g_static_mutex_trylock (&gee_hazard_pointer__queue_mutex);
1959 GeeArrayList* _tmp2_;
1960 GeeArrayList* _tmp3_;
1961 GeeArrayList* _tmp4_;
1962 _tmp1_ = gee_hazard_pointer__queue;
1963 _tmp2_ = self->_to_free;
1964 self->_to_free = NULL;
1966 gee_queue_offer (_tmp1_, _tmp3_);
1967 _g_object_unref0 (_tmp3_);
1968 _tmp4_ = gee_array_list_new (G_TYPE_POINTER, NULL, NULL, NULL, NULL, NULL);
1969 _g_object_unref0 (self->_to_free);
1970 self->_to_free = _tmp4_;
1971 g_static_mutex_unlock (&gee_hazard_pointer__queue_mutex);
1977 * Pushes the current context to releaser. Plase note that it might block.
1979 void gee_hazard_pointer_context_release (GeeHazardPointerContext* self) {
1981 GeeArrayList* _tmp1_;
1982 GeeArrayList* _tmp2_;
1983 GeeArrayList* _tmp3_;
1984 g_return_if_fail (self != NULL);
1985 g_static_mutex_lock (&gee_hazard_pointer__queue_mutex);
1986 _tmp0_ = gee_hazard_pointer__queue;
1987 _tmp1_ = self->_to_free;
1988 self->_to_free = NULL;
1990 gee_queue_offer (_tmp0_, _tmp2_);
1991 _g_object_unref0 (_tmp2_);
1992 _tmp3_ = gee_array_list_new (G_TYPE_POINTER, NULL, NULL, NULL, NULL, NULL);
1993 _g_object_unref0 (self->_to_free);
1994 self->_to_free = _tmp3_;
1995 g_static_mutex_unlock (&gee_hazard_pointer__queue_mutex);
2000 * Add pointer to freed array.
2002 inline void gee_hazard_pointer_context_release_ptr (GeeHazardPointerContext* self, void* ptr, GeeHazardPointerDestroyNotify notify, void* notify_target, GDestroyNotify notify_target_destroy_notify) {
2003 GeeHazardPointerFreeNode* _tmp0_;
2004 GeeHazardPointerFreeNode* node;
2005 GeeHazardPointerFreeNode* _tmp1_;
2007 GeeHazardPointerFreeNode* _tmp3_;
2008 GeeHazardPointerDestroyNotify _tmp4_;
2009 void* _tmp4__target;
2010 GDestroyNotify _tmp4__target_destroy_notify;
2011 GeeArrayList* _tmp5_;
2012 GeeHazardPointerFreeNode* _tmp6_;
2013 GeeArrayList* _tmp7_;
2017 g_return_if_fail (self != NULL);
2018 _tmp0_ = gee_hazard_pointer_free_node_new ();
2022 _tmp1_->pointer = _tmp2_;
2025 _tmp4__target = notify_target;
2026 _tmp4__target_destroy_notify = notify_target_destroy_notify;
2027 notify_target_destroy_notify = NULL;
2028 (_tmp3_->destroy_notify_target_destroy_notify == NULL) ? NULL : (_tmp3_->destroy_notify_target_destroy_notify (_tmp3_->destroy_notify_target), NULL);
2029 _tmp3_->destroy_notify = NULL;
2030 _tmp3_->destroy_notify_target = NULL;
2031 _tmp3_->destroy_notify_target_destroy_notify = NULL;
2032 _tmp3_->destroy_notify = _tmp4_;
2033 _tmp3_->destroy_notify_target = _tmp4__target;
2034 _tmp3_->destroy_notify_target_destroy_notify = _tmp4__target_destroy_notify;
2035 _tmp5_ = self->_to_free;
2037 gee_abstract_collection_add ((GeeAbstractCollection*) _tmp5_, _tmp6_);
2038 _tmp7_ = self->_to_free;
2039 _tmp8_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp7_);
2041 _tmp10_ = gee_hazard_pointer_context_THRESHOLD;
2042 if (((guint) _tmp9_) >= _tmp10_) {
2043 GeeArrayList* _tmp11_;
2044 _tmp11_ = self->_to_free;
2045 gee_hazard_pointer_try_free (_tmp11_);
2047 (notify_target_destroy_notify == NULL) ? NULL : (notify_target_destroy_notify (notify_target), NULL);
2049 notify_target = NULL;
2050 notify_target_destroy_notify = NULL;
2055 * Gets current context.
2057 inline GeeHazardPointerContext* gee_hazard_pointer_context_get_current_context (void) {
2058 GeeHazardPointerContext* result = NULL;
2059 void* _tmp0_ = NULL;
2060 _tmp0_ = g_static_private_get (&gee_hazard_pointer_context__current_context);
2066 static void gee_hazard_pointer_context_instance_init (GeeHazardPointerContext * self) {
2070 void gee_hazard_pointer_context_free (GeeHazardPointerContext* self) {
2071 GeeArrayList* _tmp0_;
2075 gboolean clean_parent;
2077 GeeHazardPointerContext* _tmp18_;
2079 _tmp0_ = self->_to_free;
2080 _tmp1_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp0_);
2083 clean_parent = FALSE;
2086 GeeArrayList* remaining = NULL;
2087 gboolean _tmp4_ = FALSE;
2088 GeeHazardPointerContext* _tmp5_;
2090 GeeArrayList* _tmp13_;
2091 _tmp5_ = self->_parent;
2092 if (_tmp5_ == NULL) {
2098 _tmp7_ = gee_hazard_pointer_context_THRESHOLD;
2099 _tmp4_ = ((guint) _tmp6_) >= _tmp7_;
2103 GeeHazardPointerPolicy* _tmp9_;
2104 GeeArrayList* _tmp10_;
2105 GeeArrayList* _tmp11_ = NULL;
2106 _tmp9_ = self->_policy;
2107 _tmp10_ = self->_to_free;
2108 self->_to_free = NULL;
2109 _tmp11_ = gee_hazard_pointer_policy_perform (*_tmp9_, _tmp10_);
2110 _g_object_unref0 (remaining);
2111 remaining = _tmp11_;
2113 GeeArrayList* _tmp12_;
2114 _tmp12_ = self->_to_free;
2115 self->_to_free = NULL;
2116 _g_object_unref0 (remaining);
2117 remaining = _tmp12_;
2119 _tmp13_ = remaining;
2120 if (_tmp13_ != NULL) {
2121 GeeHazardPointerContext* _tmp14_;
2122 GeeHazardPointerContext* _tmp15_;
2123 GeeArrayList* _tmp16_;
2124 GeeArrayList* _tmp17_;
2125 _tmp14_ = self->_parent;
2126 _vala_assert (_tmp14_ != NULL, "_parent != null");
2127 _tmp15_ = self->_parent;
2128 _tmp16_ = _tmp15_->_to_free;
2129 _tmp17_ = remaining;
2130 gee_array_list_add_all (_tmp16_, (GeeCollection*) _tmp17_);
2131 clean_parent = TRUE;
2133 _g_object_unref0 (remaining);
2135 _tmp18_ = self->_parent;
2136 g_static_private_set (&gee_hazard_pointer_context__current_context, _tmp18_, NULL);
2137 _tmp19_ = clean_parent;
2139 GeeHazardPointerContext* _tmp20_;
2140 GeeArrayList* _tmp21_;
2141 _tmp20_ = self->_parent;
2142 _tmp21_ = _tmp20_->_to_free;
2143 gee_hazard_pointer_try_free (_tmp21_);
2145 _g_object_unref0 (self->_to_free);
2146 _g_free0 (self->_policy);
2147 g_slice_free (GeeHazardPointerContext, self);
2151 GeeHazardPointerFreeNode* gee_hazard_pointer_free_node_new (void) {
2152 GeeHazardPointerFreeNode* self;
2153 self = g_slice_new0 (GeeHazardPointerFreeNode);
2154 gee_hazard_pointer_free_node_instance_init (self);
2159 static void gee_hazard_pointer_free_node_instance_init (GeeHazardPointerFreeNode * self) {
2163 void gee_hazard_pointer_free_node_free (GeeHazardPointerFreeNode* self) {
2164 (self->destroy_notify_target_destroy_notify == NULL) ? NULL : (self->destroy_notify_target_destroy_notify (self->destroy_notify_target), NULL);
2165 self->destroy_notify = NULL;
2166 self->destroy_notify_target = NULL;
2167 self->destroy_notify_target_destroy_notify = NULL;
2168 g_slice_free (GeeHazardPointerFreeNode, self);
2172 GeeHazardPointerNode* gee_hazard_pointer_node_new (void) {
2173 GeeHazardPointerNode* self;
2174 self = g_slice_new0 (GeeHazardPointerNode);
2175 gee_hazard_pointer_node_instance_init (self);
2176 g_atomic_pointer_set ((volatile gpointer *) (&self->_hazard), NULL);
2177 g_atomic_int_set ((volatile gint *) (&self->_active), 1);
2182 void gee_hazard_pointer_node_release (GeeHazardPointerNode* self) {
2183 g_return_if_fail (self != NULL);
2184 g_atomic_pointer_set ((volatile gpointer *) (&self->_hazard), NULL);
2185 g_atomic_int_set ((volatile gint *) (&self->_active), 0);
2189 inline gboolean gee_hazard_pointer_node_is_active (GeeHazardPointerNode* self) {
2190 gboolean result = FALSE;
2192 g_return_val_if_fail (self != NULL, FALSE);
2193 _tmp0_ = g_atomic_int_get ((volatile gint *) (&self->_active));
2194 result = _tmp0_ != 0;
2199 inline gboolean gee_hazard_pointer_node_activate (GeeHazardPointerNode* self) {
2200 gboolean result = FALSE;
2201 gboolean _tmp0_ = FALSE;
2202 g_return_val_if_fail (self != NULL, FALSE);
2203 _tmp0_ = g_atomic_int_compare_and_exchange ((volatile gint *) (&self->_active), 0, 1);
2209 inline void gee_hazard_pointer_node_set (GeeHazardPointerNode* self, void* ptr) {
2211 g_return_if_fail (self != NULL);
2213 g_atomic_pointer_set ((volatile gpointer *) (&self->_hazard), _tmp0_);
2217 inline void* gee_hazard_pointer_node_get (GeeHazardPointerNode* self, gboolean safe) {
2218 void* result = NULL;
2220 g_return_val_if_fail (self != NULL, NULL);
2223 void* _tmp1_ = NULL;
2224 _tmp1_ = g_atomic_pointer_get ((volatile gpointer *) (&self->_hazard));
2225 result = (void*) _tmp1_;
2229 _tmp2_ = self->_hazard;
2230 result = (void*) _tmp2_;
2236 inline GeeHazardPointerNode* gee_hazard_pointer_node_get_next (GeeHazardPointerNode* self) {
2237 GeeHazardPointerNode* result = NULL;
2238 void* _tmp0_ = NULL;
2239 g_return_val_if_fail (self != NULL, NULL);
2240 _tmp0_ = g_atomic_pointer_get ((volatile gpointer *) (&self->_next));
2241 result = (GeeHazardPointerNode*) _tmp0_;
2246 inline void gee_hazard_pointer_node_set_next (GeeHazardPointerNode* self, GeeHazardPointerNode* next) {
2247 GeeHazardPointerNode* _tmp0_;
2248 g_return_if_fail (self != NULL);
2250 g_atomic_pointer_set ((volatile gpointer *) (&self->_next), _tmp0_);
2254 static void gee_hazard_pointer_node_instance_init (GeeHazardPointerNode * self) {
2258 void gee_hazard_pointer_node_free (GeeHazardPointerNode* self) {
2259 GeeHazardPointerNode* _tmp0_;
2260 _tmp0_ = self->_next;
2261 gee_hazard_pointer_node_free (_tmp0_);
2262 g_slice_free (GeeHazardPointerNode, self);
2266 static void gee_hazard_pointer_instance_init (GeeHazardPointer * self) {
2270 void gee_hazard_pointer_free (GeeHazardPointer* self) {
2271 GeeHazardPointerNode* _tmp0_;
2272 _tmp0_ = self->_node;
2273 gee_hazard_pointer_node_release (_tmp0_);
2274 g_slice_free (GeeHazardPointer, self);