Permalink
Browse files

[concurrency] Initialize interp struct member in Scheduler. Add a way to

quickly check number of pending tasks, and to delete a particular task by TID.


git-svn-id: https://svn.parrot.org/parrot/trunk@23355 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
1 parent 24c7eef commit 2f43c2322bbf982ea52c48bfcc3c854814e90b55 @allisonrandal allisonrandal committed Dec 2, 2007
Showing with 34 additions and 0 deletions.
  1. +34 −0 src/pmc/scheduler.pmc
View
@@ -46,6 +46,7 @@ Initialize a concurrency scheduler object.
core_struct->task_list = pmc_new(interp, enum_class_Hash);
core_struct->task_index = pmc_new(interp, enum_class_ResizablePMCArray);
core_struct->handlers = pmc_new(interp, enum_class_ResizablePMCArray);
+ core_struct->interp = INTERP;
}
@@ -99,6 +100,39 @@ recalculate it before retrieving the next task.
/*
+=item C<INTVAL get_integer()>
+
+Retrieve the number of pending tasks in the scheduler's task list.
+
+=cut
+
+*/
+
+ INTVAL get_integer() {
+ Parrot_Scheduler * core_struct = PARROT_SCHEDULER(SELF);
+ return VTABLE_elements(INTERP, core_struct->task_index);
+ }
+
+/*
+
+=item C<void delete_keyed_int(INTVAL key)>
+
+Removes the task with the given task ID from the task list.
+
+=cut
+
+*/
+
+ void delete_keyed_int(INTVAL key) {
+ Parrot_Scheduler * core_struct = PARROT_SCHEDULER(SELF);
+ PMC * const pmc_key = pmc_new(INTERP, enum_class_Integer);
+ VTABLE_set_integer_native(INTERP, pmc_key, key);
+ VTABLE_delete_keyed(INTERP, core_struct->task_list, pmc_key);
+ SCHEDULER_cache_valid_CLEAR(SELF);
+ }
+
+/*
+
=item C<void destroy()>
Free the scheduler's underlying struct.

0 comments on commit 2f43c23

Please sign in to comment.