Skip to content

Commit

Permalink
Add a current_task method to ParrotInterpreter to get the current tas…
Browse files Browse the repository at this point in the history
…k object (if any). Add code() and data() methods to Task to get/set the code and data object
  • Loading branch information
Whiteknight committed Oct 29, 2011
1 parent 524fd09 commit 4295769
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/pmc/parrotinterpreter.pmc
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,12 @@ support it.
RETURN(INTVAL id);
}

METHOD current_task() {
Interp * const this_interp = PMC_interp(SELF);
PMC * const current_task = this_interp->cur_task;
RETURN(PMC *current_task);
}

}

/*
Expand Down
27 changes: 27 additions & 0 deletions src/pmc/task.pmc
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,33 @@ Send a message to this task.
}
}

/*
METHOD receive() {
}
*/

METHOD code(PMC * code :optional, INTVAL has_code :opt_flag) {
Parrot_Task_attributes * const tdata = PARROT_TASK(SELF);
PMC * code;
if (has_code) {
tdata->code = code;
PARROT_GC_WRITE_BARRIER(INTERP, SELF);
}
code = tdata->code;
RETURN (PMC *code);
}

METHOD data(PMC * data :optional, INTVAL has_data :opt_flag) {
Parrot_Task_attributes * const tdata = PARROT_TASK(SELF);
PMC * data;
if (has_data) {
tdata->data = data;
PARROT_GC_WRITE_BARRIER(INTERP, SELF);
}
data = tdata->data;
RETURN (PMC *data);
}

/*

=item METHOD kill()
Expand Down

0 comments on commit 4295769

Please sign in to comment.