mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-15 08:47:35 +02:00
First crack at gc_mutator_thread_runnable
This commit is contained in:
parent
cc36d6459d
commit
c09dc43dde
2 changed files with 19 additions and 7 deletions
20
gc.c
20
gc.c
|
@ -1375,13 +1375,25 @@ void gc_mutator_thread_runnable(gc_thread_data *thd, object result)
|
|||
CYC_THREAD_STATE_BLOCKED,
|
||||
CYC_THREAD_STATE_RUNNABLE);
|
||||
if (ATOMIC_GET(&(thd->collector_cooperated))) {
|
||||
// TODO:
|
||||
// wait for thd->lock
|
||||
printf("DEBUG - Collector cooperated, wait for it to finish\n");
|
||||
// wait for the collector to finish
|
||||
pthread_mutex_lock(&(thd->lock));
|
||||
pthread_mutex_unlock(&(thd->lock));
|
||||
// unset async flag
|
||||
while(!ATOMIC_SET_IF_EQ(&(thd->collector_cooperated), 1, 0)){}
|
||||
// transport result to heap, if necessary (IE, is not a value type)
|
||||
// set gc_args[0] to result
|
||||
// longjmp. assumes gc_cont already set by collector
|
||||
if (is_object_type(result)) {
|
||||
fprintf(stderr, "Unhandled object type result, TODO: implement\n");
|
||||
exit(1);
|
||||
}
|
||||
// Setup value to send to continuation
|
||||
thd->gc_args[0] = result;
|
||||
thd->gc_num_args = 1;
|
||||
// Whoa.
|
||||
printf("DEBUG - Call into gc_cont setup by collector\n");
|
||||
longjmp(*(thd->jmp_start), 1);
|
||||
} else {
|
||||
// Collector didn't do anything; make a normal continuation call
|
||||
(((closure)(thd->gc_cont))->fn)(thd, 1, thd->gc_cont, result);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2112,7 +2112,7 @@ TODO: should rename this function to make it more clear what is really going on
|
|||
*/
|
||||
void Cyc_start_thread(gc_thread_data *thd)
|
||||
{
|
||||
/* Tank, load the jump program... */
|
||||
// Tank, load the jump program
|
||||
setjmp(*(thd->jmp_start));
|
||||
|
||||
#if DEBUG_GC
|
||||
|
|
Loading…
Add table
Reference in a new issue