mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-19 21:59:16 +02:00
startup collector thread
This commit is contained in:
parent
6e6f079430
commit
c9d24c9a02
3 changed files with 22 additions and 1 deletions
21
gc.c
21
gc.c
|
@ -731,11 +731,30 @@ void gc_collector()
|
|||
//sweep :
|
||||
max_freed = gc_sweep(Cyc_get_heap(), &freed);
|
||||
#if GC_DEBUG_CONCISE_PRINTFS
|
||||
printf("sweep done, freed = %d, max_freed = %d, elapsed = %ld\n", freed, max_freed, time(NULL) - sweep_start);
|
||||
printf("sweep done, freed = %d, max_freed = %d, elapsed = %ld\n",
|
||||
freed, max_freed, time(NULL) - sweep_start);
|
||||
#endif
|
||||
gc_stage = STAGE_RESTING;
|
||||
}
|
||||
|
||||
void *collector_main(void *arg)
|
||||
{
|
||||
while (1) {
|
||||
gc_collector();
|
||||
sleep(1); // TODO: how to schedule this thread?
|
||||
}
|
||||
}
|
||||
|
||||
static pthread_t collector_thread;
|
||||
|
||||
void gc_start_collector()
|
||||
{
|
||||
if (pthread_create(&collector_thread, NULL, collector_main, &collector_thread)) {
|
||||
fprintf(stderr, "Error creating collector thread\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////
|
||||
// END tri-color marking section
|
||||
/////////////////////////////////////////////
|
||||
|
|
|
@ -29,6 +29,7 @@ static void Cyc_heap_init(long heap_size)
|
|||
#endif
|
||||
Cyc_heap = gc_heap_create(heap_size / 2, 0, 0);
|
||||
gc_init_mutators();
|
||||
gc_start_collector();
|
||||
}
|
||||
|
||||
#endif /* CYCLONE_RUNTIME_MAIN_H */
|
||||
|
|
|
@ -150,6 +150,7 @@ void gc_empty_collector_stack();
|
|||
void gc_handshake(gc_status_type s);
|
||||
void gc_post_handshake(gc_status_type s);
|
||||
void gc_wait_handshake();
|
||||
void gc_start_collector();
|
||||
gc_heap *Cyc_get_heap();
|
||||
|
||||
/////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Reference in a new issue