Browse files

Make a thread local copy of the task to run

Of course the task itself that a thread runs should belong to the
thread's interp, lest it may be garbage collected before it's time.
  • Loading branch information...
1 parent 889ef48 commit 984661b2f76f72bde8c62d3f0e53b22bba98d6c0 @niner niner committed Dec 1, 2011
Showing with 5 additions and 3 deletions.
  1. +3 −2 src/pmc/task.pmc
  2. +2 −1 src/thread.c
View
5 src/pmc/task.pmc
@@ -208,8 +208,9 @@ Create a copy of the task, resetting status, ID, and birthtime.
Parrot_Task_attributes * const new_struct = PARROT_TASK(copy);
const Parrot_Task_attributes * const old_struct = PARROT_TASK(SELF);
- new_struct->code = VTABLE_clone(INTERP, old_struct->code);
- new_struct->data = VTABLE_clone(INTERP, old_struct->data);
+ new_struct->code = VTABLE_clone(INTERP, old_struct->code);
+ new_struct->data = VTABLE_clone(INTERP, old_struct->data);
+ new_struct->shared = VTABLE_clone(INTERP, old_struct->shared);
return copy;
}
View
3 src/thread.c
@@ -143,8 +143,9 @@ Parrot_thread_schedule_task(PARROT_INTERP, ARGIN(PMC *thread), ARGIN(PMC *task))
PMC * const self = (PMC*) thread;
Parrot_Interp const thread_interp =
(Parrot_Interp)((Parrot_ParrotInterpreter_attributes *)PMC_data(self))->interp;
+ PMC * const local_task = Parrot_thread_make_local_copy(thread_interp, interp, task);
- VTABLE_push_pmc(thread_interp, thread_interp->scheduler, task);
+ VTABLE_push_pmc(thread_interp, thread_interp->scheduler, local_task);
}
/*

0 comments on commit 984661b

Please sign in to comment.