Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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