Skip to content
Newer
Older
100644 547 lines (359 sloc) 13.9 KB
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
1 /*
0e36289 @allisonrandal [cage] Updating all copyrights in src/ to Parrot Foundation.
allisonrandal authored Feb 17, 2009
2 Copyright (C) 2001-2008, Parrot Foundation.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
3 $Id$
4
5 =head1 NAME
6
7 src/pmc/scheduler.pmc - The concurrency scheduler
8
9 =head1 DESCRIPTION
10
11 Implements the core concurrency scheduler.
12
d6808fe @allisonrandal [events] Add interface for event handling, add subtype attribute to t…
allisonrandal authored Dec 12, 2007
13 =head2 Vtable Functions
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
14
15 =over 4
16
17 =cut
18
19 */
20
ec73fb3 @allisonrandal [concurrency] Divide scheduler headers into public and private (for c…
allisonrandal authored Dec 6, 2007
21 #include "parrot/scheduler_private.h"
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
22
6b81760 @Whiteknight [pmc] we don't need need_ext anymore, so BALEETED
Whiteknight authored Aug 23, 2009
23 pmclass Scheduler auto_attrs {
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
24
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
25 ATTR INTVAL id; /* The scheduler's ID. */
26 ATTR INTVAL max_tid; /* The highest assigned task ID. */
27 ATTR INTVAL pending; /* A count of pending tasks (cached for fast
28 lookup). */
29 ATTR PMC *task_list; /* The current list of tasks. */
30 ATTR PMC *task_index; /* An index into the current list of tasks,
31 ordered by priority. */
32 ATTR PMC *wait_index; /* An unordered index of inactive tasks. */
33 ATTR PMC *handlers; /* The list of currently active handlers. */
34 ATTR PMC *messages; /* A message queue used for communication
35 between schedulers. */
36 ATTR Parrot_mutex msg_lock; /* Lock to synchronize the message queue. */
37 ATTR Parrot_Interp interp; /* A link to the scheduler's interpreter. */
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
38
39 /*
40
41 =item C<void init()>
42
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
43 Initializes a concurrency scheduler object.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
44
45 =cut
46
47 */
48
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
49 VTABLE void init() {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored Sep 8, 2008
50 Parrot_Scheduler_attributes * const core_struct =
5a7584e @NotFound merge auto_attrs branch into trunk
NotFound authored Aug 18, 2009
51 (Parrot_Scheduler_attributes *) PMC_data(SELF);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
52
1997c49 @cotto [gc] remove/replace DOD references in core PMCs
cotto authored Feb 12, 2009
53 /* Set flags for custom GC mark and destroy. */
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
54 PObj_custom_mark_SET(SELF);
4591dbb @chromatic [HLL] Fixed two compilation-breaking typos accidentally committed in …
chromatic authored Sep 3, 2009
55 PObj_custom_destroy_SET(SELF);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
56
57 /* Set up the core struct. */
58 core_struct->id = 0;
59 core_struct->max_tid = 0;
60 core_struct->task_list = pmc_new(interp, enum_class_Hash);
245b0a8 @allisonrandal [concurrency] Change an array of task IDs to an integer array rather …
allisonrandal authored Dec 6, 2007
61 core_struct->task_index = pmc_new(interp, enum_class_ResizableIntegerArray);
98ca8df @allisonrandal [concurrency] Further work on the new concurrency scheduler. (With ap…
allisonrandal authored Dec 31, 2007
62 core_struct->wait_index = pmc_new(interp, enum_class_ResizablePMCArray);
4d9c960 @allisonrandal [concurrency] Next stage of concurrency implementation, message passi…
allisonrandal authored Jan 5, 2008
63 core_struct->handlers = pmc_new(interp, enum_class_ResizablePMCArray);
64 core_struct->messages = pmc_new(interp, enum_class_ResizablePMCArray);
2f43c23 @allisonrandal [concurrency] Initialize interp struct member in Scheduler. Add a way to
allisonrandal authored Dec 2, 2007
65 core_struct->interp = INTERP;
4d9c960 @allisonrandal [concurrency] Next stage of concurrency implementation, message passi…
allisonrandal authored Jan 5, 2008
66 MUTEX_INIT(core_struct->msg_lock);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
67 }
68
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
69
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
70 /*
71
96858ee @chromatic [PMC] Added init_pmc() to Scheduler PMC, with tests.
chromatic authored Dec 3, 2007
72 =item C<void init_pmc(PMC *data)>
73
74 Initializes a new Scheduler with a C<Hash> PMC with any or all of the keys:
75
76 =over 4
77
78 =item C<id>
79
80 An C<Integer> representing the unique identifier for this scheduler.
81
82 =back
83
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
84 =cut
85
96858ee @chromatic [PMC] Added init_pmc() to Scheduler PMC, with tests.
chromatic authored Dec 3, 2007
86 */
87
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
88 VTABLE void init_pmc(PMC *data) {
96858ee @chromatic [PMC] Added init_pmc() to Scheduler PMC, with tests.
chromatic authored Dec 3, 2007
89 PMC *elem;
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored Sep 8, 2008
90 Parrot_Scheduler_attributes *core_struct;
96858ee @chromatic [PMC] Added init_pmc() to Scheduler PMC, with tests.
chromatic authored Dec 3, 2007
91
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
92 if (!VTABLE_isa(INTERP, data, CONST_STRING(INTERP, "Hash")))
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
93 Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_INVALID_OPERATION,
4d9c960 @allisonrandal [concurrency] Next stage of concurrency implementation, message passi…
allisonrandal authored Jan 5, 2008
94 "Scheduler initializer must be a Hash");
96858ee @chromatic [PMC] Added init_pmc() to Scheduler PMC, with tests.
chromatic authored Dec 3, 2007
95
4d9c960 @allisonrandal [concurrency] Next stage of concurrency implementation, message passi…
allisonrandal authored Jan 5, 2008
96 SELF.init();
96858ee @chromatic [PMC] Added init_pmc() to Scheduler PMC, with tests.
chromatic authored Dec 3, 2007
97
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
98 core_struct = PARROT_SCHEDULER(SELF);
99 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 Dec 3, 2007
100
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
101 if (!PMC_IS_NULL(elem))
102 core_struct->id = VTABLE_get_integer(INTERP, elem);
96858ee @chromatic [PMC] Added init_pmc() to Scheduler PMC, with tests.
chromatic authored Dec 3, 2007
103 }
104
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
105
96858ee @chromatic [PMC] Added init_pmc() to Scheduler PMC, with tests.
chromatic authored Dec 3, 2007
106 /*
107
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
108 =item C<void push_pmc(PMC *value)>
109
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
110 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 Dec 31, 2007
111 current maximum, and a birthtime of the current time.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
112
113 =cut
114
115 */
116
e922116 @allisonrandal [concurrency] Initial implementation of concurrency scheduler runloop.
allisonrandal authored Dec 4, 2007
117 void push_pmc(PMC *task) {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored Sep 8, 2008
118 Parrot_Scheduler_attributes * const core_struct = PARROT_SCHEDULER(SELF);
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
119 STRING *task_id_str;
120 INTVAL new_tid;
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
121
98ca8df @allisonrandal [concurrency] Further work on the new concurrency scheduler. (With ap…
allisonrandal authored Dec 31, 2007
122 task = VTABLE_share_ro(INTERP, task);
123 VTABLE_set_number_native(INTERP, task, Parrot_floatval_time());
d0fb13e @allisonrandal [concurrency] Tasks are marked as shared before being inserted into t…
allisonrandal authored Dec 6, 2007
124
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
125 new_tid = ++(core_struct->max_tid);
98ca8df @allisonrandal [concurrency] Further work on the new concurrency scheduler. (With ap…
allisonrandal authored Dec 31, 2007
126 VTABLE_set_integer_native(INTERP, task, new_tid);
b6bc0c3 @allisonrandal [pdd28str] Merging the pdd27mmd branch into trunk for r36123 to r36318.
allisonrandal authored Feb 3, 2009
127 task_id_str = Parrot_str_from_int(INTERP, new_tid);
245b0a8 @allisonrandal [concurrency] Change an array of task IDs to an integer array rather …
allisonrandal authored Dec 6, 2007
128
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
129 VTABLE_set_pmc_keyed_str(INTERP, core_struct->task_list,
130 task_id_str, task);
98ca8df @allisonrandal [concurrency] Further work on the new concurrency scheduler. (With ap…
allisonrandal authored Dec 31, 2007
131
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
132 if (task->vtable->base_type == enum_class_Timer)
98ca8df @allisonrandal [concurrency] Further work on the new concurrency scheduler. (With ap…
allisonrandal authored Dec 31, 2007
133 VTABLE_push_integer(INTERP, core_struct->wait_index, new_tid);
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
134 else
98ca8df @allisonrandal [concurrency] Further work on the new concurrency scheduler. (With ap…
allisonrandal authored Dec 31, 2007
135 VTABLE_push_integer(INTERP, core_struct->task_index, new_tid);
136
137 SCHEDULER_cache_valid_CLEAR(SELF);
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
138
139 if (task->vtable->base_type != enum_class_Exception)
140 Parrot_cx_runloop_wake(core_struct->interp, SELF);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
141 }
142
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
143
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
144 /*
145
146 =item C<PMC *pop_pmc()>
147
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
148 Retrieves the next task from the task list. If the task index is invalid,
149 recalculates it before retrieving the next task.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
150
151 =cut
152
153 */
154
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
155 VTABLE PMC *pop_pmc() {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored Sep 8, 2008
156 Parrot_Scheduler_attributes * core_struct = PARROT_SCHEDULER(SELF);
98ca8df @allisonrandal [concurrency] Further work on the new concurrency scheduler. (With ap…
allisonrandal authored Dec 31, 2007
157 PMC *task = PMCNULL;
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
158
98ca8df @allisonrandal [concurrency] Further work on the new concurrency scheduler. (With ap…
allisonrandal authored Dec 31, 2007
159 /* Pull the next valid task off the task list, skipping expired and
160 * deleted tasks. */
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
161 while (PMC_IS_NULL(task)
162 && VTABLE_elements(INTERP, core_struct->task_index) > 0) {
d0fb13e @allisonrandal [concurrency] Tasks are marked as shared before being inserted into t…
allisonrandal authored Dec 6, 2007
163 INTVAL tid = VTABLE_shift_integer(INTERP, core_struct->task_index);
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
164
98ca8df @allisonrandal [concurrency] Further work on the new concurrency scheduler. (With ap…
allisonrandal authored Dec 31, 2007
165 if (tid > 0)
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
166 task = VTABLE_get_pmc_keyed_int(INTERP,
167 core_struct->task_list, tid);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
168 }
169
98ca8df @allisonrandal [concurrency] Further work on the new concurrency scheduler. (With ap…
allisonrandal authored Dec 31, 2007
170 return task;
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
171 }
172
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
173
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
174 /*
175
2f43c23 @allisonrandal [concurrency] Initialize interp struct member in Scheduler. Add a way to
allisonrandal authored Dec 2, 2007
176 =item C<INTVAL get_integer()>
177
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
178 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 Dec 2, 2007
179
180 =cut
181
182 */
183
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
184 VTABLE INTVAL get_integer() {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored Sep 8, 2008
185 Parrot_Scheduler_attributes * core_struct = PARROT_SCHEDULER(SELF);
2f43c23 @allisonrandal [concurrency] Initialize interp struct member in Scheduler. Add a way to
allisonrandal authored Dec 2, 2007
186 return VTABLE_elements(INTERP, core_struct->task_index);
187 }
188
d6808fe @allisonrandal [events] Add interface for event handling, add subtype attribute to t…
allisonrandal authored Dec 12, 2007
189
2f43c23 @allisonrandal [concurrency] Initialize interp struct member in Scheduler. Add a way to
allisonrandal authored Dec 2, 2007
190 /*
191
192 =item C<void delete_keyed_int(INTVAL key)>
193
194 Removes the task with the given task ID from the task list.
195
196 =cut
197
198 */
199
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
200 VTABLE void delete_keyed_int(INTVAL key) {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored Sep 8, 2008
201 Parrot_Scheduler_attributes *core_struct = PARROT_SCHEDULER(SELF);
b6bc0c3 @allisonrandal [pdd28str] Merging the pdd27mmd branch into trunk for r36123 to r36318.
allisonrandal authored Feb 3, 2009
202 STRING *task_id_str = Parrot_str_from_int(INTERP, key);
98ca8df @allisonrandal [concurrency] Further work on the new concurrency scheduler. (With ap…
allisonrandal authored Dec 31, 2007
203 VTABLE_delete_keyed_str(INTERP, core_struct->task_list, task_id_str);
2f43c23 @allisonrandal [concurrency] Initialize interp struct member in Scheduler. Add a way to
allisonrandal authored Dec 2, 2007
204 SCHEDULER_cache_valid_CLEAR(SELF);
205 }
206
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
207
2f43c23 @allisonrandal [concurrency] Initialize interp struct member in Scheduler. Add a way to
allisonrandal authored Dec 2, 2007
208 /*
209
e922116 @allisonrandal [concurrency] Initial implementation of concurrency scheduler runloop.
allisonrandal authored Dec 4, 2007
210 =item C<PMC *share_ro()>
211
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
212 Sets this PMC as shared.
e922116 @allisonrandal [concurrency] Initial implementation of concurrency scheduler runloop.
allisonrandal authored Dec 4, 2007
213
214 =cut
215
216 */
217
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
218 VTABLE PMC *share_ro() {
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
219 PMC *shared_self;
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored Sep 8, 2008
220 Parrot_Scheduler_attributes *sched;
e922116 @allisonrandal [concurrency] Initial implementation of concurrency scheduler runloop.
allisonrandal authored Dec 4, 2007
221
222 if (PObj_is_PMC_shared_TEST(SELF))
223 return SELF;
224
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
225 shared_self = pt_shared_fixup(INTERP, SELF);
226 sched = PARROT_SCHEDULER(shared_self);
e922116 @allisonrandal [concurrency] Initial implementation of concurrency scheduler runloop.
allisonrandal authored Dec 4, 2007
227
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
228 sched->task_list = pt_shared_fixup(INTERP, sched->task_list);
229 sched->task_index = pt_shared_fixup(INTERP, sched->task_index);
230 sched->wait_index = pt_shared_fixup(INTERP, sched->wait_index);
231 sched->handlers = pt_shared_fixup(INTERP, sched->handlers);
232 sched->messages = pt_shared_fixup(INTERP, sched->messages);
e922116 @allisonrandal [concurrency] Initial implementation of concurrency scheduler runloop.
allisonrandal authored Dec 4, 2007
233
234 return shared_self;
235 }
236
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
237
e922116 @allisonrandal [concurrency] Initial implementation of concurrency scheduler runloop.
allisonrandal authored Dec 4, 2007
238 /*
239
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
240 =item C<void destroy()>
241
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
242 Frees the scheduler's underlying struct.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
243
244 =cut
245
246 */
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
247 VTABLE void destroy() {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored Sep 8, 2008
248 Parrot_Scheduler_attributes * const core_struct = PARROT_SCHEDULER(SELF);
540d4c3 @bacek Merge context_pmc3 branch into trunk.
bacek authored Sep 3, 2009
249 /* TT #946: this line is causing an order-of-destruction error
250 because the scheduler is being freed before it's tasks.
251 Commenting this out till we get a real fix (although it's a hack) */
252 /* MUTEX_DESTROY(core_struct->msg_lock); */
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
253 }
254
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
255
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
256 /*
257
258 =item C<void mark()>
259
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
260 Marks any referenced strings and PMCs as live.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
261
262 =cut
263
264 */
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
265 VTABLE void mark() {
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
266 if (PARROT_SCHEDULER(SELF)) {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored Sep 8, 2008
267 Parrot_Scheduler_attributes * const core_struct = PARROT_SCHEDULER(SELF);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
268
18dd147 @NotFound [gc] add new mark_... _alive functions, use it in a lot of mark vtabl…
NotFound authored Sep 24, 2009
269 Parrot_gc_mark_PMC_alive(interp, core_struct->task_list);
270 Parrot_gc_mark_PMC_alive(interp, core_struct->task_index);
271 Parrot_gc_mark_PMC_alive(interp, core_struct->wait_index);
272 Parrot_gc_mark_PMC_alive(interp, core_struct->handlers);
273 Parrot_gc_mark_PMC_alive(interp, core_struct->messages);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
274 }
275 }
276
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
277
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
278 /*
279
b101f2c @darbelo Merge pmc_freeze_with_pmcs into trunk.
darbelo authored Feb 2, 2010
280 =item C<void visit(PMC *info)>
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
281
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
282 Visits the contents of the scheduler (used by freeze/thaw).
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
283
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
284 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 Nov 25, 2007
285
286 =cut
287
288 */
289
b101f2c @darbelo Merge pmc_freeze_with_pmcs into trunk.
darbelo authored Feb 2, 2010
290 VTABLE void visit(PMC *info) {
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
291 /* 1) visit task list */
4c43475 @plobsing merge branch pmc_freeze_cleanup
plobsing authored Jan 13, 2010
292 VISIT_PMC_ATTR(INTERP, info, SELF, Scheduler, task_list);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
293
294 /* 2) visit the handlers */
4c43475 @plobsing merge branch pmc_freeze_cleanup
plobsing authored Jan 13, 2010
295 VISIT_PMC_ATTR(INTERP, info, SELF, Scheduler, handlers);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
296 }
297
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
298
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
299 /*
300
b101f2c @darbelo Merge pmc_freeze_with_pmcs into trunk.
darbelo authored Feb 2, 2010
301 =item C<void freeze(PMC *info)>
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
302
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
303 Archives the scheduler.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
304
305 =cut
306
307 */
308
b101f2c @darbelo Merge pmc_freeze_with_pmcs into trunk.
darbelo authored Feb 2, 2010
309 VTABLE void freeze(PMC *info) {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored Sep 8, 2008
310 Parrot_Scheduler_attributes * const core_struct = PARROT_SCHEDULER(SELF);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
311
312 /* 1) freeze scheduler id */
4c43475 @plobsing merge branch pmc_freeze_cleanup
plobsing authored Jan 13, 2010
313 VTABLE_push_integer(INTERP, info, core_struct->id);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
314
315 /* 2) freeze maximum task id */
4c43475 @plobsing merge branch pmc_freeze_cleanup
plobsing authored Jan 13, 2010
316 VTABLE_push_integer(INTERP, info, core_struct->max_tid);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
317 }
318
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
319
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
320 /*
321
b101f2c @darbelo Merge pmc_freeze_with_pmcs into trunk.
darbelo authored Feb 2, 2010
322 =item C<void thaw(PMC *info)>
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
323
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
324 Unarchives the scheduler.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
325
326 =cut
327
328 */
329
b101f2c @darbelo Merge pmc_freeze_with_pmcs into trunk.
darbelo authored Feb 2, 2010
330 VTABLE void thaw(PMC *info) {
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
331 /* 1. thaw scheduler id */
4c43475 @plobsing merge branch pmc_freeze_cleanup
plobsing authored Jan 13, 2010
332 const INTVAL id = VTABLE_shift_integer(INTERP, info);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
333
334 /* 2. thaw maximum task id */
4c43475 @plobsing merge branch pmc_freeze_cleanup
plobsing authored Jan 13, 2010
335 const INTVAL max_tid = VTABLE_shift_integer(INTERP, info);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
336
337 /* Allocate the scheduler's core data struct and set custom flags. */
338 SELF.init();
339
340 /* Set the scheduler's id to the frozen id */
341 PARROT_SCHEDULER(SELF)->id = id;
342
343 /* Set the scheduler's maximum task id to the frozen tid */
344 PARROT_SCHEDULER(SELF)->max_tid = max_tid;
345 }
346
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
347
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
348 /*
349
b101f2c @darbelo Merge pmc_freeze_with_pmcs into trunk.
darbelo authored Feb 2, 2010
350 =item C<void thawfinish(PMC *info)>
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
351
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
352 Finishes thawing the scheduler.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
353
354 =cut
355
356 */
357
b101f2c @darbelo Merge pmc_freeze_with_pmcs into trunk.
darbelo authored Feb 2, 2010
358 VTABLE void thawfinish(PMC *info) {
4d9c960 @allisonrandal [concurrency] Next stage of concurrency implementation, message passi…
allisonrandal authored Jan 5, 2008
359 Parrot_cx_refresh_task_list(INTERP, SELF);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
360 }
361
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
362
d6808fe @allisonrandal [events] Add interface for event handling, add subtype attribute to t…
allisonrandal authored Dec 12, 2007
363 /*
364
365 =back
366
367 =head2 Methods
368
369 =over 4
370
371 =cut
372
373 */
374
375 /*
376
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
377 =item C<METHOD add_handler(PMC *handler)>
d6808fe @allisonrandal [events] Add interface for event handling, add subtype attribute to t…
allisonrandal authored Dec 12, 2007
378
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
379 Adds a handler to the scheduler.
d6808fe @allisonrandal [events] Add interface for event handling, add subtype attribute to t…
allisonrandal authored Dec 12, 2007
380
381 =cut
382
383 */
384
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
385 METHOD add_handler(PMC *handler) {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored Sep 8, 2008
386 Parrot_Scheduler_attributes *core_struct = PARROT_SCHEDULER(SELF);
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
387 VTABLE_unshift_pmc(INTERP, core_struct->handlers, handler);
388 }
389
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
390
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
391 /*
392
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
393 =item C<METHOD delete_handler(STRING *type :optional, INTVAL have_type :opt_flag)>
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
394
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
395 Deletes a handler from the scheduler.
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
396
397 =cut
398
399 */
400
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
401 METHOD delete_handler(STRING *type :optional, INTVAL have_type :opt_flag) {
402 PMC *handlers;
403 INTVAL elements, index;
404 STRING *except_str = CONST_STRING(INTERP, "exception");
405 STRING *event_str = CONST_STRING(INTERP, "event");
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
406
407 GET_ATTR_handlers(INTERP, SELF, handlers);
408 elements = VTABLE_elements(INTERP, handlers);
409
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
410 if (!have_type)
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
411 VTABLE_shift_pmc(INTERP, handlers);
412
413 /* Loop from newest handler to oldest handler. */
414 for (index = 0; index < elements; ++index) {
415 PMC *handler = VTABLE_get_pmc_keyed_int(INTERP, handlers, index);
416 if (!PMC_IS_NULL(handler)) {
4b380b1 @Util [cage] (TT #397) PDD07 enforcement for Parrot_str_not_equal(foo,bar)==0
Util authored Mar 3, 2009
417 if (Parrot_str_equal(INTERP, type, except_str)
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
418 && handler->vtable->base_type == enum_class_ExceptionHandler) {
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
419 VTABLE_set_pmc_keyed_int(INTERP, handlers, index, PMCNULL);
420 RETURN(void);
421 }
4b380b1 @Util [cage] (TT #397) PDD07 enforcement for Parrot_str_not_equal(foo,bar)==0
Util authored Mar 3, 2009
422 else if (Parrot_str_equal(INTERP, type, event_str)
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
423 && handler->vtable->base_type == enum_class_EventHandler) {
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
424 VTABLE_set_pmc_keyed_int(INTERP, handlers, index, PMCNULL);
425 RETURN(void);
426 }
427 }
428 }
429
430 Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
431 "No handler to delete.");
d6808fe @allisonrandal [events] Add interface for event handling, add subtype attribute to t…
allisonrandal authored Dec 12, 2007
432 }
98ca8df @allisonrandal [concurrency] Further work on the new concurrency scheduler. (With ap…
allisonrandal authored Dec 31, 2007
433
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
434
d6808fe @allisonrandal [events] Add interface for event handling, add subtype attribute to t…
allisonrandal authored Dec 12, 2007
435 /*
436
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
437 =item C<METHOD find_handler(PMC *task)>
d6808fe @allisonrandal [events] Add interface for event handling, add subtype attribute to t…
allisonrandal authored Dec 12, 2007
438
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
439 Searchs for a handler for the given task. If no handler is found, returns
d6808fe @allisonrandal [events] Add interface for event handling, add subtype attribute to t…
allisonrandal authored Dec 12, 2007
440 PMCNULL.
441
442 =cut
443
444 */
445
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
446 METHOD find_handler(PMC *task) {
0006ce7 @chromatic [src] Fixed all CONST_STRING macros so that they don't break across l…
chromatic authored Dec 19, 2008
447 STRING * const handled_str = CONST_STRING(interp, "handled");
448 STRING * const iter_str = CONST_STRING(interp, "handler_iter");
449 PMC *iter;
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
450
451 /* Exceptions store the handler iterator for rethrow, other kinds of
452 * tasks don't (though they could). */
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
453 if (task->vtable->base_type == enum_class_Exception
0006ce7 @chromatic [src] Fixed all CONST_STRING macros so that they don't break across l…
chromatic authored Dec 19, 2008
454 && VTABLE_get_integer_keyed_str(interp, task, handled_str) == -1) {
455 iter = VTABLE_get_attr_str(interp, task, iter_str);
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
456 }
457 else {
458 PMC *handlers;
459 GET_ATTR_handlers(interp, SELF, handlers);
460 iter = VTABLE_get_iter(interp, handlers);
461
462 if (task->vtable->base_type == enum_class_Exception)
0006ce7 @chromatic [src] Fixed all CONST_STRING macros so that they don't break across l…
chromatic authored Dec 19, 2008
463 VTABLE_set_attr_str(interp, task, iter_str, iter);
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
464 }
465
466 /* Loop from newest handler to oldest handler. */
467 while (VTABLE_get_bool(interp, iter)) {
468 PMC *handler = VTABLE_shift_pmc(INTERP, iter);
d6808fe @allisonrandal [events] Add interface for event handling, add subtype attribute to t…
allisonrandal authored Dec 12, 2007
469
470 INTVAL valid_handler = 0;
471 if (!PMC_IS_NULL(handler)) {
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
472 (INTVAL valid_handler) = PCCINVOKE(INTERP, handler, "can_handle", PMC *task);
d6808fe @allisonrandal [events] Add interface for event handling, add subtype attribute to t…
allisonrandal authored Dec 12, 2007
473 if (valid_handler) {
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
474 if (task->vtable->base_type == enum_class_Exception)
475 VTABLE_set_integer_native(interp, handler, 1);
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
476 RETURN(PMC *handler);
d6808fe @allisonrandal [events] Add interface for event handling, add subtype attribute to t…
allisonrandal authored Dec 12, 2007
477 }
478 }
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
479
d6808fe @allisonrandal [events] Add interface for event handling, add subtype attribute to t…
allisonrandal authored Dec 12, 2007
480 }
481
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
482 RETURN(PMC *PMCNULL);
98ca8df @allisonrandal [concurrency] Further work on the new concurrency scheduler. (With ap…
allisonrandal authored Dec 31, 2007
483 }
484
d6808fe @allisonrandal [events] Add interface for event handling, add subtype attribute to t…
allisonrandal authored Dec 12, 2007
485
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
486 /*
487
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
488 =item C<METHOD count_handlers(STRING *type :optional, INTVAL have_type :opt_flag)>
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
489
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
490 Returns the number of handlers currently held by the scheduler. If a type
491 argument is passed, only counts handlers of that type (C<event>, C<exception>).
492 If no type argument is passed, counts all handlers.
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
493
494 =cut
495
496 */
497
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
498 METHOD count_handlers(STRING *type :optional, INTVAL have_type :opt_flag) {
499 /* avoid uninitialized value warning */
500 PMC *handlers = NULL;
9f26f43 @NotFound fix count_eh opcode and add test for it, TT #212 rg++
NotFound authored Jan 25, 2009
501 INTVAL elements;
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
502 INTVAL count = 0;
503 INTVAL index;
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
504
505 GET_ATTR_handlers(INTERP, SELF, handlers);
9f26f43 @NotFound fix count_eh opcode and add test for it, TT #212 rg++
NotFound authored Jan 25, 2009
506 elements = VTABLE_elements(INTERP, handlers);
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
507
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
508 if (!have_type)
509 RETURN(INTVAL elements);
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
510
511 for (index = 0; index < elements; ++index) {
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
512 PMC *handler = VTABLE_get_pmc_keyed_int(INTERP, handlers, index);
513 STRING *exception = CONST_STRING(INTERP, "exception");
514 STRING *event = CONST_STRING(INTERP, "event");
515
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
516 if (!PMC_IS_NULL(handler)) {
4b380b1 @Util [cage] (TT #397) PDD07 enforcement for Parrot_str_not_equal(foo,bar)==0
Util authored Mar 3, 2009
517 if ((Parrot_str_equal(INTERP, type, exception)
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
518 && handler->vtable->base_type == enum_class_ExceptionHandler)
4b380b1 @Util [cage] (TT #397) PDD07 enforcement for Parrot_str_not_equal(foo,bar)==0
Util authored Mar 3, 2009
519 || (Parrot_str_equal(INTERP, type, event)
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
520 && handler->vtable->base_type == enum_class_EventHandler))
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
521 count++;
522 }
523 }
524
525 RETURN(INTVAL count);
526 }
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
527 }
528
529 /*
530
531 =back
532
533 =head1 SEE ALSO
534
4d9c960 @allisonrandal [concurrency] Next stage of concurrency implementation, message passi…
allisonrandal authored Jan 5, 2008
535 F<docs/pdds/pdd25_concurrency.pod>.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
536
537 =cut
538
539 */
540
541 /*
542 * Local variables:
543 * c-file-style: "parrot"
544 * End:
545 * vim: expandtab shiftwidth=4:
546 */
Something went wrong with that request. Please try again.