#include <mono/utils/mono-linked-list-set.h>
-/*atomics.*/
-#include <mono/io-layer/io-layer.h>
+#include <mono/utils/atomic.h>
static inline gpointer
mask (gpointer n, uintptr_t bit)
/*
Initialize @list and will use @free_node_func to release memory.
-If @free_node_func is null the caller is responsible for releasing node memory.
+If @free_node_func is null the caller is responsible for releasing node memory.
+@free_node_func must be lock-free. That implies that it cannot use malloc/free.
*/
void
mono_lls_init (MonoLinkedListSet *list, void (*free_node_func)(void *))
mono_memory_write_barrier ();
mono_hazard_pointer_clear (hp, 1);
if (list->free_node_func)
- mono_thread_hazardous_free_or_queue (cur, list->free_node_func);
+ mono_thread_hazardous_free_or_queue (cur, list->free_node_func, FALSE, TRUE);
} else
goto try_again;
}
continue;
/* The second CAS must happen before the first. */
mono_memory_write_barrier ();
- if (InterlockedCompareExchangePointer ((volatile gpointer*)prev, next, cur) == cur) {
+ if (InterlockedCompareExchangePointer ((volatile gpointer*)prev, mono_lls_pointer_unmask (next), cur) == cur) {
/* The CAS must happen before the hazard pointer clear. */
mono_memory_write_barrier ();
mono_hazard_pointer_clear (hp, 1);
if (list->free_node_func)
- mono_thread_hazardous_free_or_queue (value, list->free_node_func);
+ mono_thread_hazardous_free_or_queue (value, list->free_node_func, FALSE, TRUE);
} else
mono_lls_find (list, hp, value->key);
return TRUE;