void sgen_gray_object_queue_init_with_alloc_prepare (SgenGrayQueue *queue, GrayQueueAllocPrepareFunc func, void *data) { sgen_gray_object_queue_init (queue); queue->alloc_prepare_func = func; queue->alloc_prepare_data = data; }
void sgen_gray_object_queue_init_with_alloc_prepare (SgenGrayQueue *queue, GrayQueueEnqueueCheckFunc enqueue_check_func, GrayQueueAllocPrepareFunc alloc_prepare_func, void *data) { sgen_gray_object_queue_init (queue, enqueue_check_func); sgen_gray_queue_set_alloc_prepare (queue, alloc_prepare_func, data); }
void sgen_gray_object_queue_init_invalid (SgenGrayQueue *queue) { sgen_gray_object_queue_init (queue, FALSE); queue->alloc_prepare_func = invalid_prepare_func; queue->alloc_prepare_data = NULL; }
void sgen_workers_init_distribute_gray_queue (void) { if (!sgen_collection_is_parallel ()) return; sgen_gray_object_queue_init (&workers_distribute_gray_queue); }
static mono_native_thread_return_t workers_thread_func (void *data_untyped) { WorkerData *data = data_untyped; mono_thread_info_register_small_id (); if (sgen_get_major_collector ()->init_worker_thread) sgen_get_major_collector ()->init_worker_thread (data->major_collector_data); sgen_gray_object_queue_init_with_alloc_prepare (&data->private_gray_queue, workers_gray_queue_share_redirect, data); for (;;) { gboolean did_work = FALSE; while (workers_dequeue_and_do_job (data)) { did_work = TRUE; /* FIXME: maybe distribute the gray queue here? */ } if (workers_marking && (!sgen_gray_object_queue_is_empty (&data->private_gray_queue) || workers_get_work (data))) { g_assert (!sgen_gray_object_queue_is_empty (&data->private_gray_queue)); while (!sgen_drain_gray_stack (&data->private_gray_queue, 32)) workers_gray_queue_share_redirect (&data->private_gray_queue); g_assert (sgen_gray_object_queue_is_empty (&data->private_gray_queue)); sgen_gray_object_queue_init (&data->private_gray_queue); did_work = TRUE; } if (!did_work) workers_wait (); } /* dummy return to make compilers happy */ return NULL; }
static void init_private_gray_queue (WorkerData *data) { sgen_gray_object_queue_init (&data->private_gray_queue, sgen_get_major_collector ()->is_concurrent ? concurrent_enqueue_check : NULL); }