in src/clds_hazard_pointers.c [346:398]
CLDS_HAZARD_POINTERS_HANDLE clds_hazard_pointers_create(void)
{
CLDS_HAZARD_POINTERS_HANDLE result;
result = malloc(sizeof(CLDS_HAZARD_POINTERS));
if (result == NULL)
{
LogError("malloc failed");
}
else
{
result->hp_thread_cleanup_worker = worker_thread_create(hp_thread_cleanup_func, result);
if (result->hp_thread_cleanup_worker == NULL)
{
LogError("worker_thread_create failed");
}
else
{
if (worker_thread_open(result->hp_thread_cleanup_worker) != 0)
{
LogError("worker_thread_open failed");
}
else
{
TQUEUE(CLDS_HP_INACTIVE_THREAD) inactive_threads = TQUEUE_CREATE(CLDS_HP_INACTIVE_THREAD)(INITIAL_INACTIVE_THREADS_QUEUE_SIZE, MAX_INACTIVE_THREADS_QUEUE_SIZE, NULL, NULL, NULL);
if (inactive_threads == NULL)
{
LogError("TQUEUE_CREATE(CLDS_HP_INACTIVE_THREAD)(INACTIVE_THREADS_QUEUE_SIZE, false) failed");
}
else
{
TQUEUE_INITIALIZE_MOVE(CLDS_HP_INACTIVE_THREAD)(&result->inactive_threads, &inactive_threads);
result->reclaim_threshold = DEFAULT_RECLAIM_THRESHOLD;
(void)interlocked_exchange_pointer((void* volatile_atomic*) & result->head, NULL);
(void)interlocked_exchange_64(&result->epoch, 0);
(void)interlocked_exchange(&result->pending_reclaim_calls, 0);
goto all_ok;
}
worker_thread_close(result->hp_thread_cleanup_worker);
}
worker_thread_destroy(result->hp_thread_cleanup_worker);
}
free(result);
result = NULL;
}
all_ok:
return result;
}