Skip to content

HTTPS clone URL

Subversion checkout URL

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