From 64be028166dc588269d7cfc8a5c2650777feb32a Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Sat, 17 Jun 2017 01:01:59 -0400 Subject: [PATCH] Added gc_is_mutator_active() --- gc.c | 12 ++++++++++++ include/cyclone/types.h | 1 + 2 files changed, 13 insertions(+) diff --git a/gc.c b/gc.c index 0491d66f..c45cb4b1 100644 --- a/gc.c +++ b/gc.c @@ -195,6 +195,18 @@ void gc_remove_mutator(gc_thread_data * thd) pthread_mutex_unlock(&mutators_lock); } +int gc_is_mutator_active(gc_thread_data *thd) +{ + ck_array_iterator_t iterator; + gc_thread_data *m; + CK_ARRAY_FOREACH(&Cyc_mutators, &iterator, &m) { + if (m == thd) { + return 1; + } + } + return 0; +} + /** * @brief Free thread data for all terminated mutators */ diff --git a/include/cyclone/types.h b/include/cyclone/types.h index ca6bebcd..3c8c5c94 100644 --- a/include/cyclone/types.h +++ b/include/cyclone/types.h @@ -306,6 +306,7 @@ struct gc_thread_data_t { void gc_initialize(void); void gc_add_mutator(gc_thread_data * thd); void gc_remove_mutator(gc_thread_data * thd); +int gc_is_mutator_active(gc_thread_data *thd); gc_heap *gc_heap_create(int heap_type, size_t size, size_t max_size, size_t chunk_size, gc_thread_data *thd); gc_heap *gc_heap_free(gc_heap *page, gc_heap *prev_page);