Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 338 lines (208 sloc) 7.478 kB
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
1 /*
3f0c008 @NotFound use a hash keyed by int in Schecduler task_list to avoid string-int c…
NotFound authored
2 Copyright (C) 2001-2011, Parrot Foundation.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
3
4 =head1 NAME
5
6 src/pmc/scheduler.pmc - The concurrency scheduler
7
8 =head1 DESCRIPTION
9
10 Implements the core concurrency scheduler.
11
d6808fe @allisonrandal [events] Add interface for event handling, add subtype attribute to t…
allisonrandal authored
12 =head2 Vtable Functions
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
13
14 =over 4
15
16 =cut
17
18 */
19
ec73fb3 @allisonrandal [concurrency] Divide scheduler headers into public and private (for c…
allisonrandal authored
20 #include "parrot/scheduler_private.h"
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
21
6bdd5f9 @petdance headerizer now runs on PMC files
petdance authored
22 /* HEADERIZER HFILE: none */
23 /* HEADERIZER BEGIN: static */
24 /* HEADERIZER END: static */
25
6b81760 @Whiteknight [pmc] we don't need need_ext anymore, so BALEETED
Whiteknight authored
26 pmclass Scheduler auto_attrs {
fb0dfd8 @NatTuck Progress on alarms / timers.
NatTuck authored
27 ATTR INTVAL id; /* The scheduler's ID. */
28 ATTR PMC *handlers; /* The list of currently active handlers. */
29 ATTR PMC *messages; /* A message queue used for communication
30 between schedulers. */
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored
31
9f3e20d @NatTuck [gsoc_threads] Alarms work, at least the easy way.
NatTuck authored
32 ATTR PMC *task_queue; /* List of tasks/green threads waiting to run */
33 ATTR PMC *alarms; /* List of future alarms ordered by time */
fb0dfd8 @NatTuck Progress on alarms / timers.
NatTuck authored
34
9110bb8 @NatTuck [gsoc_threads] More green threads API.
NatTuck authored
35 ATTR PMC *all_tasks; /* Hash of all active tasks by ID */
36 ATTR UINTVAL next_task_id; /* ID to assign to the next created task */
37
fb0dfd8 @NatTuck Progress on alarms / timers.
NatTuck authored
38 ATTR Parrot_Interp interp; /* A link to the scheduler's interpreter. */
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
39
40 /*
41
42 =item C<void init()>
43
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored
44 Initializes a concurrency scheduler object.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
45
46 =cut
47
48 */
49
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
50 VTABLE void init() {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored
51 Parrot_Scheduler_attributes * const core_struct =
5a7584e @NotFound merge auto_attrs branch into trunk
NotFound authored
52 (Parrot_Scheduler_attributes *) PMC_data(SELF);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
53
1997c49 @cotto [gc] remove/replace DOD references in core PMCs
cotto authored
54 /* Set flags for custom GC mark and destroy. */
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
55 PObj_custom_mark_SET(SELF);
4591dbb @chromatic [HLL] Fixed two compilation-breaking typos accidentally committed in …
chromatic authored
56 PObj_custom_destroy_SET(SELF);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
57
58 /* Set up the core struct. */
9110bb8 @NatTuck [gsoc_threads] More green threads API.
NatTuck authored
59 core_struct->id = 0;
60 core_struct->handlers = Parrot_pmc_new(INTERP, enum_class_ResizablePMCArray);
61 core_struct->messages = Parrot_pmc_new(INTERP, enum_class_ResizablePMCArray);
62 core_struct->task_queue = Parrot_pmc_new(INTERP, enum_class_PMCList);
63 core_struct->alarms = Parrot_pmc_new(INTERP, enum_class_PMCList);
64 core_struct->all_tasks = Parrot_pmc_new(INTERP, enum_class_Hash);
65 core_struct->next_task_id = 0;
66 core_struct->interp = INTERP;
67
68 /* Chandon TODO: Delete from int-keyed hash doesn't like me. */
69 /* VTABLE_set_integer_native(interp, core_struct->all_tasks, Hash_key_type_int); */
70
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
71 }
72
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored
73
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
74 /*
75
96858ee @chromatic [PMC] Added init_pmc() to Scheduler PMC, with tests.
chromatic authored
76 =item C<void init_pmc(PMC *data)>
77
78 Initializes a new Scheduler with a C<Hash> PMC with any or all of the keys:
79
80 =over 4
81
82 =item C<id>
83
84 An C<Integer> representing the unique identifier for this scheduler.
85
86 =back
87
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored
88 =cut
89
96858ee @chromatic [PMC] Added init_pmc() to Scheduler PMC, with tests.
chromatic authored
90 */
91
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
92 VTABLE void init_pmc(PMC *data) {
96858ee @chromatic [PMC] Added init_pmc() to Scheduler PMC, with tests.
chromatic authored
93 PMC *elem;
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored
94 Parrot_Scheduler_attributes *core_struct;
96858ee @chromatic [PMC] Added init_pmc() to Scheduler PMC, with tests.
chromatic authored
95
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored
96 if (!VTABLE_isa(INTERP, data, CONST_STRING(INTERP, "Hash")))
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored
97 Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_INVALID_OPERATION,
4d9c960 @allisonrandal [concurrency] Next stage of concurrency implementation, message passi…
allisonrandal authored
98 "Scheduler initializer must be a Hash");
96858ee @chromatic [PMC] Added init_pmc() to Scheduler PMC, with tests.
chromatic authored
99
4d9c960 @allisonrandal [concurrency] Next stage of concurrency implementation, message passi…
allisonrandal authored
100 SELF.init();
96858ee @chromatic [PMC] Added init_pmc() to Scheduler PMC, with tests.
chromatic authored
101
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored
102 core_struct = PARROT_SCHEDULER(SELF);
103 elem = VTABLE_get_pmc_keyed_str(INTERP, data, CONST_STRING(INTERP, "id"));
96858ee @chromatic [PMC] Added init_pmc() to Scheduler PMC, with tests.
chromatic authored
104
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored
105 if (!PMC_IS_NULL(elem))
106 core_struct->id = VTABLE_get_integer(INTERP, elem);
96858ee @chromatic [PMC] Added init_pmc() to Scheduler PMC, with tests.
chromatic authored
107 }
108
109 /*
110
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
111 =item C<void push_pmc(PMC *value)>
112
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored
113 Inserts a task into the task list, giving it a task ID one higher than the
98ca8df @allisonrandal [concurrency] Further work on the new concurrency scheduler. (With ap…
allisonrandal authored
114 current maximum, and a birthtime of the current time.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
115
116 =cut
117
118 */
119
e922116 @allisonrandal [concurrency] Initial implementation of concurrency scheduler runloop.
allisonrandal authored
120 void push_pmc(PMC *task) {
5d8728e @NatTuck [gsoc_threads] Fix some failing tests.
NatTuck authored
121 Parrot_Scheduler_attributes *const core_struct = PARROT_SCHEDULER(SELF);
98ca8df @allisonrandal [concurrency] Further work on the new concurrency scheduler. (With ap…
allisonrandal authored
122
5d8728e @NatTuck [gsoc_threads] Fix some failing tests.
NatTuck authored
123 PMC *const type_pmc = VTABLE_get_attr_str(interp, task, CONST_STRING(interp, "type"));
124 STRING *const type = VTABLE_get_string(interp, type_pmc);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
125 }
126
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored
127
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
128 /*
129
130 =item C<PMC *pop_pmc()>
131
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored
132 Retrieves the next task from the task list. If the task index is invalid,
133 recalculates it before retrieving the next task.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
134
135 =cut
136
137 */
138
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
139 VTABLE PMC *pop_pmc() {
62b52c9 @NatTuck [gsoc_threads] Added callback PMC to handle NCI.
NatTuck authored
140 Parrot_Scheduler_attributes *core_struct = PARROT_SCHEDULER(SELF);
141 PMC *task = VTABLE_shift_pmc(INTERP, core_struct->task_queue);
98ca8df @allisonrandal [concurrency] Further work on the new concurrency scheduler. (With ap…
allisonrandal authored
142 return task;
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
143 }
144
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored
145
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
146 /*
147
2f43c23 @allisonrandal [concurrency] Initialize interp struct member in Scheduler. Add a way to
allisonrandal authored
148 =item C<INTVAL get_integer()>
149
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored
150 Retrieves the number of pending tasks in the scheduler's task list.
2f43c23 @allisonrandal [concurrency] Initialize interp struct member in Scheduler. Add a way to
allisonrandal authored
151
152 =cut
153
154 */
155
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
156 VTABLE INTVAL get_integer() {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored
157 Parrot_Scheduler_attributes * core_struct = PARROT_SCHEDULER(SELF);
856f3b2 @niner Cleanup green_threads/kill_threads merge, builds now
niner authored
158 return VTABLE_elements(INTERP, core_struct->task_queue);
e922116 @allisonrandal [concurrency] Initial implementation of concurrency scheduler runloop.
allisonrandal authored
159 }
160
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored
161
e922116 @allisonrandal [concurrency] Initial implementation of concurrency scheduler runloop.
allisonrandal authored
162 /*
163
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
164 =item C<void destroy()>
165
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored
166 Frees the scheduler's underlying struct.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
167
168 =cut
169
170 */
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
171 VTABLE void destroy() {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored
172 Parrot_Scheduler_attributes * const core_struct = PARROT_SCHEDULER(SELF);
40787d4 @Whiteknight [gc] Gix order-of-destruction bug discovered by Chandon++. The check …
Whiteknight authored
173 core_struct->interp->scheduler = NULL;
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
174 }
175
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored
176
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
177 /*
178
179 =item C<void mark()>
180
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored
181 Marks any referenced strings and PMCs as live.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
182
183 =cut
184
185 */
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
186 VTABLE void mark() {
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
187 if (PARROT_SCHEDULER(SELF)) {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored
188 Parrot_Scheduler_attributes * const core_struct = PARROT_SCHEDULER(SELF);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
189
26914e1 changed interp in pmc class to INTERP for unification
Jimmy Zhuo authored
190 Parrot_gc_mark_PMC_alive(INTERP, core_struct->handlers);
191 Parrot_gc_mark_PMC_alive(INTERP, core_struct->messages);
9f3e20d @NatTuck [gsoc_threads] Alarms work, at least the easy way.
NatTuck authored
192 Parrot_gc_mark_PMC_alive(INTERP, core_struct->task_queue);
193 Parrot_gc_mark_PMC_alive(INTERP, core_struct->alarms);
9110bb8 @NatTuck [gsoc_threads] More green threads API.
NatTuck authored
194 Parrot_gc_mark_PMC_alive(INTERP, core_struct->all_tasks);
5d8728e @NatTuck [gsoc_threads] Fix some failing tests.
NatTuck authored
195 }
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
196 }
197
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored
198
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
199 /*
200
b101f2c @darbelo Merge pmc_freeze_with_pmcs into trunk.
darbelo authored
201 =item C<void visit(PMC *info)>
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
202
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored
203 Visits the contents of the scheduler (used by freeze/thaw).
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
204
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored
205 C<*info> is the visit info (see F<include/parrot/pmc_freeze.h>).
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
206
207 =cut
208
209 */
210
b101f2c @darbelo Merge pmc_freeze_with_pmcs into trunk.
darbelo authored
211 VTABLE void visit(PMC *info) {
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
212 /* 1) visit task list */
62b52c9 @NatTuck [gsoc_threads] Added callback PMC to handle NCI.
NatTuck authored
213 VISIT_PMC_ATTR(INTERP, info, SELF, Scheduler, task_queue);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
214
215 /* 2) visit the handlers */
4c43475 @plobsing merge branch pmc_freeze_cleanup
plobsing authored
216 VISIT_PMC_ATTR(INTERP, info, SELF, Scheduler, handlers);
62b52c9 @NatTuck [gsoc_threads] Added callback PMC to handle NCI.
NatTuck authored
217
218 /* 3) visit the alarms */
219 VISIT_PMC_ATTR(INTERP, info, SELF, Scheduler, alarms);
9110bb8 @NatTuck [gsoc_threads] More green threads API.
NatTuck authored
220
221 /* 3) visit all tasks */
222 VISIT_PMC_ATTR(INTERP, info, SELF, Scheduler, all_tasks);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
223 }
224
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored
225
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
226 /*
227
b101f2c @darbelo Merge pmc_freeze_with_pmcs into trunk.
darbelo authored
228 =item C<void freeze(PMC *info)>
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
229
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored
230 Archives the scheduler.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
231
232 =cut
233
234 */
235
b101f2c @darbelo Merge pmc_freeze_with_pmcs into trunk.
darbelo authored
236 VTABLE void freeze(PMC *info) {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored
237 Parrot_Scheduler_attributes * const core_struct = PARROT_SCHEDULER(SELF);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
238
239 /* 1) freeze scheduler id */
4c43475 @plobsing merge branch pmc_freeze_cleanup
plobsing authored
240 VTABLE_push_integer(INTERP, info, core_struct->id);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
241 }
242
243 /*
244
b101f2c @darbelo Merge pmc_freeze_with_pmcs into trunk.
darbelo authored
245 =item C<void thaw(PMC *info)>
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
246
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored
247 Unarchives the scheduler.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
248
249 =cut
250
251 */
252
b101f2c @darbelo Merge pmc_freeze_with_pmcs into trunk.
darbelo authored
253 VTABLE void thaw(PMC *info) {
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
254 /* 1. thaw scheduler id */
4c43475 @plobsing merge branch pmc_freeze_cleanup
plobsing authored
255 const INTVAL id = VTABLE_shift_integer(INTERP, info);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
256
257 /* Allocate the scheduler's core data struct and set custom flags. */
258 SELF.init();
259
260 /* Set the scheduler's id to the frozen id */
261 PARROT_SCHEDULER(SELF)->id = id;
262 }
263
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored
264
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
265 /*
266
b101f2c @darbelo Merge pmc_freeze_with_pmcs into trunk.
darbelo authored
267 =item C<void thawfinish(PMC *info)>
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
268
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored
269 Finishes thawing the scheduler.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
270
271 =cut
272
273 */
274
b101f2c @darbelo Merge pmc_freeze_with_pmcs into trunk.
darbelo authored
275 VTABLE void thawfinish(PMC *info) {
5d8728e @NatTuck [gsoc_threads] Fix some failing tests.
NatTuck authored
276 /* Parrot_cx_refresh_task_list(INTERP, SELF); */
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
277 }
278
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored
279
d6808fe @allisonrandal [events] Add interface for event handling, add subtype attribute to t…
allisonrandal authored
280 /*
281
282 =back
283
284 =head2 Methods
285
286 =over 4
287
288 =cut
289
290 */
291
292 /*
293
9110bb8 @NatTuck [gsoc_threads] More green threads API.
NatTuck authored
294 =item C<METHOD active_tasks()>
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored
295
9110bb8 @NatTuck [gsoc_threads] More green threads API.
NatTuck authored
296 Returns a ResizablePMCArray containing pointers to all active tasks.
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored
297
298 =cut
299
300 */
301
9110bb8 @NatTuck [gsoc_threads] More green threads API.
NatTuck authored
302 METHOD active_tasks() {
303 Parrot_Scheduler_attributes *sdata = PARROT_SCHEDULER(SELF);
304 PMC *tasks = Parrot_pmc_new(interp, enum_class_ResizablePMCArray);
305 PMC *iter = Parrot_pmc_new_init(interp, enum_class_HashIterator, sdata->all_tasks);
306
307 while (!VTABLE_get_bool(interp, iter)) {
308 PMC *pair = VTABLE_shift_pmc(interp, iter);
309 PMC *task;
310 STRING *value = CONST_STRING(interp, "value");
311 Parrot_pcc_invoke_method_from_c_args(interp, pair,
312 value, "->P", task);
313 VTABLE_push_pmc(interp, tasks, task);
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored
314 }
315
9110bb8 @NatTuck [gsoc_threads] More green threads API.
NatTuck authored
316 RETURN(PMC* tasks);
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored
317 }
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
318 }
319
320 /*
321
322 =back
323
324 =head1 SEE ALSO
325
4d9c960 @allisonrandal [concurrency] Next stage of concurrency implementation, message passi…
allisonrandal authored
326 F<docs/pdds/pdd25_concurrency.pod>.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
327
328 =cut
329
330 */
331
332 /*
333 * Local variables:
334 * c-file-style: "parrot"
335 * End:
1d7dded @plobsing update C file vim modelines
plobsing authored
336 * vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
337 */
Something went wrong with that request. Please try again.