Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 346 lines (216 sloc) 7.957 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 conv...
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 task...
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 codi...
allisonrandal authored
20 #include "parrot/scheduler_private.h"
1d259c6 allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
21
6bdd5f9 Andy Lester headerizer now runs on PMC files
petdance authored
22 /* HEADERIZER HFILE: none */
23 /* HEADERIZER BEGIN: static */
24 /* HEADERIZER END: static */
25
6b81760 Andrew Whitworth [pmc] we don't need need_ext anymore, so BALEETED
Whiteknight authored
26 pmclass Scheduler auto_attrs {
fb0dfd8 Nat Tuck 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 Nat Tuck [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 Nat Tuck Progress on alarms / timers.
NatTuck authored
34
9110bb8 Nat Tuck [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 Andrew Whitworth rename enable_event_checking -> Parrot_runcore_enable_event_checking, di...
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 Nat Tuck [gsoc_threads] More green threads API.
NatTuck authored
41
fb0dfd8 Nat Tuck 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 tided...
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>_attribu...
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 r40...
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 Nat Tuck [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 Andrew Whitworth rename enable_event_checking -> Parrot_runcore_enable_event_checking, di...
Whiteknight authored
69 core_struct->enable_scheduling = 0;
70 core_struct->enable_preemption = 0;
9110bb8 Nat Tuck [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 tided...
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 tided...
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>_attribu...
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 tided...
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 passing ...
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 passing ...
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 tided...
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 tided...
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 tided...
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 apolo...
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 Andrew Whitworth 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>_attribu...
NotFound authored
128 Parrot_Scheduler_attributes * const core_struct = PARROT_SCHEDULER(SELF);
9ddac31 Andrew Whitworth cleanup Scheduler.pmc and Task.pmc. Add const for the optimizer. Fix a b...
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 tided...
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 tided...
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 Andrew Whitworth cleanup Scheduler.pmc and Task.pmc. Add const for the optimizer. Fix a b...
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 apolo...
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 tided...
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 tided...
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 Andy Lester removed unused var task_id_str. Consted a pointer, and marked an interp ...
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 tided...
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 tided...
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() {
971e997 NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attribu...
NotFound authored
178 Parrot_Scheduler_attributes * const core_struct = PARROT_SCHEDULER(SELF);
fd1a800 Andy Lester removed unused var task_id_str. Consted a pointer, and marked an interp ...
petdance authored
179 UNUSED(interp);
180
40787d4 Andrew Whitworth [gc] Gix order-of-destruction bug discovered by Chandon++. The check for...
Whiteknight authored
181 core_struct->interp->scheduler = NULL;
1d259c6 allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
182 }
183
be7602b chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and tided...
chromatic authored
184
1d259c6 allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
185 /*
186
187 =item C<void mark()>
188
be7602b chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and tided...
chromatic authored
189 Marks any referenced strings and PMCs as live.
1d259c6 allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
190
191 =cut
192
193 */
59661f1 allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
194 VTABLE void mark() {
1d259c6 allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
195 if (PARROT_SCHEDULER(SELF)) {
971e997 NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attribu...
NotFound authored
196 Parrot_Scheduler_attributes * const core_struct = PARROT_SCHEDULER(SELF);
1d259c6 allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
197
26914e1 changed interp in pmc class to INTERP for unification
Jimmy Zhuo authored
198 Parrot_gc_mark_PMC_alive(INTERP, core_struct->handlers);
199 Parrot_gc_mark_PMC_alive(INTERP, core_struct->messages);
9f3e20d Nat Tuck [gsoc_threads] Alarms work, at least the easy way.
NatTuck authored
200 Parrot_gc_mark_PMC_alive(INTERP, core_struct->task_queue);
201 Parrot_gc_mark_PMC_alive(INTERP, core_struct->alarms);
9110bb8 Nat Tuck [gsoc_threads] More green threads API.
NatTuck authored
202 Parrot_gc_mark_PMC_alive(INTERP, core_struct->all_tasks);
5d8728e Nat Tuck [gsoc_threads] Fix some failing tests.
NatTuck authored
203 }
1d259c6 allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
204 }
205
be7602b chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and tided...
chromatic authored
206
1d259c6 allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
207 /*
208
b101f2c Daniel Arbelo Arrocha Merge pmc_freeze_with_pmcs into trunk.
darbelo authored
209 =item C<void visit(PMC *info)>
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 tided...
chromatic authored
211 Visits the contents of the scheduler (used by freeze/thaw).
1d259c6 allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
212
be7602b chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and tided...
chromatic authored
213 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
214
215 =cut
216
217 */
218
b101f2c Daniel Arbelo Arrocha Merge pmc_freeze_with_pmcs into trunk.
darbelo authored
219 VTABLE void visit(PMC *info) {
1d259c6 allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
220 /* 1) visit task list */
62b52c9 Nat Tuck [gsoc_threads] Added callback PMC to handle NCI.
NatTuck authored
221 VISIT_PMC_ATTR(INTERP, info, SELF, Scheduler, task_queue);
1d259c6 allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
222
223 /* 2) visit the handlers */
4c43475 Peter Lobsinger merge branch pmc_freeze_cleanup
plobsing authored
224 VISIT_PMC_ATTR(INTERP, info, SELF, Scheduler, handlers);
62b52c9 Nat Tuck [gsoc_threads] Added callback PMC to handle NCI.
NatTuck authored
225
226 /* 3) visit the alarms */
227 VISIT_PMC_ATTR(INTERP, info, SELF, Scheduler, alarms);
9110bb8 Nat Tuck [gsoc_threads] More green threads API.
NatTuck authored
228
229 /* 3) visit all tasks */
230 VISIT_PMC_ATTR(INTERP, info, SELF, Scheduler, all_tasks);
1d259c6 allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
231 }
232
be7602b chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and tided...
chromatic authored
233
1d259c6 allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
234 /*
235
b101f2c Daniel Arbelo Arrocha Merge pmc_freeze_with_pmcs into trunk.
darbelo authored
236 =item C<void freeze(PMC *info)>
1d259c6 allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
237
be7602b chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and tided...
chromatic authored
238 Archives the scheduler.
1d259c6 allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
239
240 =cut
241
242 */
243
b101f2c Daniel Arbelo Arrocha Merge pmc_freeze_with_pmcs into trunk.
darbelo authored
244 VTABLE void freeze(PMC *info) {
971e997 NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attribu...
NotFound authored
245 Parrot_Scheduler_attributes * const core_struct = PARROT_SCHEDULER(SELF);
1d259c6 allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
246
247 /* 1) freeze scheduler id */
4c43475 Peter Lobsinger merge branch pmc_freeze_cleanup
plobsing authored
248 VTABLE_push_integer(INTERP, info, core_struct->id);
1d259c6 allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
249 }
250
251 /*
252
b101f2c Daniel Arbelo Arrocha Merge pmc_freeze_with_pmcs into trunk.
darbelo authored
253 =item C<void thaw(PMC *info)>
1d259c6 allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
254
be7602b chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and tided...
chromatic authored
255 Unarchives the scheduler.
1d259c6 allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
256
257 =cut
258
259 */
260
b101f2c Daniel Arbelo Arrocha Merge pmc_freeze_with_pmcs into trunk.
darbelo authored
261 VTABLE void thaw(PMC *info) {
1d259c6 allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
262 /* 1. thaw scheduler id */
4c43475 Peter Lobsinger merge branch pmc_freeze_cleanup
plobsing authored
263 const INTVAL id = VTABLE_shift_integer(INTERP, info);
1d259c6 allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
264
265 /* Allocate the scheduler's core data struct and set custom flags. */
266 SELF.init();
267
268 /* Set the scheduler's id to the frozen id */
269 PARROT_SCHEDULER(SELF)->id = id;
270 }
271
be7602b chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and tided...
chromatic authored
272
1d259c6 allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
273 /*
274
b101f2c Daniel Arbelo Arrocha Merge pmc_freeze_with_pmcs into trunk.
darbelo authored
275 =item C<void thawfinish(PMC *info)>
1d259c6 allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
276
be7602b chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and tided...
chromatic authored
277 Finishes thawing the scheduler.
1d259c6 allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
278
279 =cut
280
281 */
282
b101f2c Daniel Arbelo Arrocha Merge pmc_freeze_with_pmcs into trunk.
darbelo authored
283 VTABLE void thawfinish(PMC *info) {
5d8728e Nat Tuck [gsoc_threads] Fix some failing tests.
NatTuck authored
284 /* Parrot_cx_refresh_task_list(INTERP, SELF); */
1d259c6 allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
285 }
286
be7602b chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and tided...
chromatic authored
287
d6808fe allisonrandal [events] Add interface for event handling, add subtype attribute to task...
allisonrandal authored
288 /*
289
290 =back
291
292 =head2 Methods
293
294 =over 4
295
296 =cut
297
298 */
299
300 /*
301
9110bb8 Nat Tuck [gsoc_threads] More green threads API.
NatTuck authored
302 =item C<METHOD active_tasks()>
2255840 allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored
303
9110bb8 Nat Tuck [gsoc_threads] More green threads API.
NatTuck authored
304 Returns a ResizablePMCArray containing pointers to all active tasks.
2255840 allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored
305
306 =cut
307
308 */
309
9110bb8 Nat Tuck [gsoc_threads] More green threads API.
NatTuck authored
310 METHOD active_tasks() {
311 Parrot_Scheduler_attributes *sdata = PARROT_SCHEDULER(SELF);
9ddac31 Andrew Whitworth cleanup Scheduler.pmc and Task.pmc. Add const for the optimizer. Fix a b...
Whiteknight authored
312 PMC * const tasks = Parrot_pmc_new(interp, enum_class_ResizablePMCArray);
313 PMC * const iter = Parrot_pmc_new_init(interp, enum_class_HashIterator, sdata->all_tasks);
9110bb8 Nat Tuck [gsoc_threads] More green threads API.
NatTuck authored
314
315 while (!VTABLE_get_bool(interp, iter)) {
9ddac31 Andrew Whitworth cleanup Scheduler.pmc and Task.pmc. Add const for the optimizer. Fix a b...
Whiteknight authored
316 PMC * const pair = VTABLE_shift_pmc(interp, iter);
317 PMC * task = PMCNULL;
318 STRING * const value = CONST_STRING(interp, "value");
9110bb8 Nat Tuck [gsoc_threads] More green threads API.
NatTuck authored
319 Parrot_pcc_invoke_method_from_c_args(interp, pair,
9ddac31 Andrew Whitworth cleanup Scheduler.pmc and Task.pmc. Add const for the optimizer. Fix a b...
Whiteknight authored
320 value, "->P", &task);
9110bb8 Nat Tuck [gsoc_threads] More green threads API.
NatTuck authored
321 VTABLE_push_pmc(interp, tasks, task);
2255840 allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored
322 }
323
9110bb8 Nat Tuck [gsoc_threads] More green threads API.
NatTuck authored
324 RETURN(PMC* tasks);
2255840 allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored
325 }
1d259c6 allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
326 }
327
328 /*
329
330 =back
331
332 =head1 SEE ALSO
333
4d9c960 allisonrandal [concurrency] Next stage of concurrency implementation, message passing ...
allisonrandal authored
334 F<docs/pdds/pdd25_concurrency.pod>.
1d259c6 allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
335
336 =cut
337
338 */
339
340 /*
341 * Local variables:
342 * c-file-style: "parrot"
343 * End:
1d7dded Peter Lobsinger update C file vim modelines
plobsing authored
344 * vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
1d259c6 allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored
345 */
Something went wrong with that request. Please try again.