diff --git a/gc.c b/gc.c index 6ceb823e..103afa85 100644 --- a/gc.c +++ b/gc.c @@ -57,6 +57,23 @@ void gc_init_mutators() } } +// Add data for a new mutator +void gc_add_mutator(gc_thread_data *thd) +{ + // TODO: need to sync access to these static variables. both here and + // elsewhere in the module!! + int i; + for (i = 0; i < Cyc_num_mutators; i++) { + if (!Cyc_mutators[i]) { + Cyc_mutators[i] = thd; + return; + } + } + // TODO: unable to create any more mutators. what to do??? + fprintf(stderr, "Unable to create a new thread, exiting\n"); + exit(1); +} + gc_heap *gc_heap_create(size_t size, size_t max_size, size_t chunk_size) { gc_free_list *free, *next; diff --git a/include/cyclone/types.h b/include/cyclone/types.h index aaf8d84a..dbf06449 100644 --- a/include/cyclone/types.h +++ b/include/cyclone/types.h @@ -126,6 +126,7 @@ void vpbuffer_free(void **buf); /* GC prototypes */ void gc_init_mutators(); +void gc_add_mutator(gc_thread_data *thd); gc_heap *gc_heap_create(size_t size, size_t max_size, size_t chunk_size); int gc_grow_heap(gc_heap *h, size_t size, size_t chunk_size); void *gc_try_alloc(gc_heap *h, size_t size);