Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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