@@ -57,11 +57,9 @@ TaskGroup* swift::swift_task_group_create(AsyncTask *task) {
57
57
TaskGroupTaskStatusRecord (reinterpret_cast <TaskGroup*>(allocation));
58
58
59
59
TaskGroup *group = new (allocation) TaskGroup (record);
60
- fprintf (stderr, " [%s:%d] (%s): create group; task: %d, group:%d\n " , __FILE__, __LINE__, __FUNCTION__, task, group);
61
60
62
61
// ok, now that the group actually is initialized: attach it to the task
63
62
swift_task_addStatusRecord (task, record);
64
- fprintf (stderr, " [%s:%d] (%s): attach GROUP, task record in parent [%d]; record:%d\n " , __FILE__, __LINE__, __FUNCTION__, task, record);
65
63
66
64
return group;
67
65
}
@@ -73,8 +71,6 @@ void swift::swift_task_group_attachChild(TaskGroup *group,
73
71
AsyncTask *parent, AsyncTask *child) {
74
72
auto groupRecord = group->getTaskRecord ();
75
73
assert (groupRecord->getGroup () == group);
76
- fprintf (stderr, " [%s:%d] (%s): attach GROUP CHILD, task:%d, group record:%d, child:%d\n " , __FILE__, __LINE__, __FUNCTION__,
77
- parent, groupRecord, child);
78
74
return groupRecord->attachChild (child);
79
75
}
80
76
@@ -87,7 +83,6 @@ void swift::swift_task_group_destroy(AsyncTask *task, TaskGroup *group) {
87
83
88
84
void TaskGroup::destroy (AsyncTask *task) {
89
85
// First, remove the group from the task and deallocate the record
90
- fprintf (stderr, " [%s:%d] (%s): detach GROUP, task:%d, group record:%d, group:%d\n " , __FILE__, __LINE__, __FUNCTION__, task, Record, this );
91
86
swift_task_removeStatusRecord (task, Record);
92
87
swift_task_dealloc (task, Record);
93
88
@@ -117,8 +112,6 @@ void TaskGroup::offer(AsyncTask *completedTask, AsyncContext *context,
117
112
assert (completedTask->hasGroupChildFragment ());
118
113
assert (completedTask->groupChildFragment ()->getGroup () == this );
119
114
120
- fprintf (stderr, " [%s:%d] (%s): offer %d\n " , __FILE__, __LINE__, __FUNCTION__, completedTask);
121
-
122
115
mutex.lock (); // TODO: remove fragment lock, and use status for synchronization
123
116
124
117
// Immediately increment ready count and acquire the status
@@ -129,8 +122,6 @@ void TaskGroup::offer(AsyncTask *completedTask, AsyncContext *context,
129
122
// W:n R:0 P:1 -> W:y R:1 P:3 // complete immediately, 2 more pending tasks
130
123
auto assumed = statusAddReadyAssumeAcquire ();
131
124
132
- fprintf (stderr, " [%s:%d] (%s): offer %s\n " , __FILE__, __LINE__, __FUNCTION__, assumed.to_string ().c_str ());
133
-
134
125
// If an error was thrown, save it in the future fragment.
135
126
auto futureContext = static_cast <FutureAsyncContext *>(context);
136
127
bool hadErrorResult = false ;
@@ -142,9 +133,7 @@ void TaskGroup::offer(AsyncTask *completedTask, AsyncContext *context,
142
133
// ==== a) has waiting task, so let us complete it right away
143
134
if (assumed.hasWaitingTask ()) {
144
135
auto waitingTask = waitQueue.load (std::memory_order_acquire);
145
- fprintf (stderr, " [%s:%d] (%s): has waiter! waiter:%d %s\n " , __FILE__, __LINE__, __FUNCTION__, waitingTask, assumed.to_string ().c_str ());
146
136
while (true ) {
147
- fprintf (stderr, " [%s:%d] (%s): run waiting task directly!\n " , __FILE__, __LINE__, __FUNCTION__);
148
137
// ==== a) run waiting task directly -------------------------------------
149
138
assert (assumed.hasWaitingTask ());
150
139
assert (assumed.pendingTasks () && " offered to group with no pending tasks!" );
@@ -155,15 +144,11 @@ void TaskGroup::offer(AsyncTask *completedTask, AsyncContext *context,
155
144
/* success*/ std::memory_order_release,
156
145
/* failure*/ std::memory_order_acquire) &&
157
146
statusCompletePendingReadyWaiting (assumed)) {
158
- fprintf (stderr, " [%s:%d] (%s): offer, claimed task!\n " , __FILE__, __LINE__, __FUNCTION__);
159
- fprintf (stderr, " [%s:%d] (%s): status now! assumed: %s\n " , __FILE__, __LINE__, __FUNCTION__, assumed.to_string ().c_str ());
160
- fprintf (stderr, " [%s:%d] (%s): status now! load: %s\n " , __FILE__, __LINE__, __FUNCTION__, statusLoadRelaxed ().to_string ().c_str ());
161
147
// Run the task.
162
148
auto result = PollResult::get (
163
149
completedTask, hadErrorResult, /* needsRelease*/ false );
164
150
165
151
mutex.unlock (); // TODO: remove fragment lock, and use status for synchronization
166
- fprintf (stderr, " [%s:%d] (%s): RUN waiting:%d with result completed:%d\n " , __FILE__, __LINE__, __FUNCTION__, waitingTask, completedTask);
167
152
swift::runTaskWithPollResult (waitingTask, completingExecutor, result);
168
153
return ;
169
154
} // else, try again
@@ -189,7 +174,6 @@ void TaskGroup::offer(AsyncTask *completedTask, AsyncContext *context,
189
174
190
175
assert (completedTask == readyItem.getTask ());
191
176
assert (readyItem.getTask ()->isFuture ());
192
- fprintf (stderr, " [%s:%d] (%s): enqueue in ready queue %d\n " , __FILE__, __LINE__, __FUNCTION__, completedTask);
193
177
readyQueue.enqueue (readyItem);
194
178
mutex.unlock (); // TODO: remove fragment lock, and use status for synchronization
195
179
return ;
@@ -207,29 +191,16 @@ void swift::swift_task_group_wait_next(
207
191
waitingTask->ResumeContext = rawContext;
208
192
209
193
auto context = static_cast <TaskGroupNextWaitAsyncContext *>(rawContext);
210
- fprintf (stderr, " [%s:%d] (%s): context %d\n " , __FILE__, __LINE__, __FUNCTION__, context);
211
194
auto task = context->task ;
212
195
auto group = context->group ;
213
- fprintf (stderr, " [%s:%d] (%s): task %d\n " , __FILE__, __LINE__, __FUNCTION__, task);
214
- fprintf (stderr, " [%s:%d] (%s): waitingTask %d\n " , __FILE__, __LINE__, __FUNCTION__, waitingTask);
215
- fprintf (stderr, " [%s:%d] (%s): group %d\n " , __FILE__, __LINE__, __FUNCTION__, group);
216
196
TaskGroup::PollResult polled = group->poll (waitingTask);
217
- fprintf (stderr, " [%s:%d] (%s): group polled: %d\n " , __FILE__, __LINE__, __FUNCTION__, polled.status );
218
197
219
198
if (polled.status == TaskGroup::GroupPollStatus::MustWait) {
220
- fprintf (stderr, " [%s:%d] (%s): group polled: WAITING\n " , __FILE__, __LINE__, __FUNCTION__);
221
199
// The waiting task has been queued on the channel,
222
200
// there were pending tasks so it will be woken up eventually.
223
201
return ;
224
202
}
225
203
226
- if (polled.status == TaskGroup::GroupPollStatus::Empty)
227
- fprintf (stderr, " [%s:%d] (%s): group polled: RUN EMPTY\n " , __FILE__, __LINE__, __FUNCTION__);
228
- if (polled.status == TaskGroup::GroupPollStatus::Success)
229
- fprintf (stderr, " [%s:%d] (%s): group polled: RUN SUCCESS\n " , __FILE__, __LINE__, __FUNCTION__);
230
- if (polled.status == TaskGroup::GroupPollStatus::Error)
231
- fprintf (stderr, " [%s:%d] (%s): group polled: RUN ERROR\n " , __FILE__, __LINE__, __FUNCTION__);
232
-
233
204
runTaskWithPollResult (waitingTask, executor, polled);
234
205
}
235
206
@@ -241,16 +212,12 @@ TaskGroup::PollResult TaskGroup::poll(AsyncTask *waitingTask) {
241
212
result.storage = nullptr ;
242
213
result.retainedTask = nullptr ;
243
214
244
- fprintf (stderr, " [%s:%d] (%s): status %s\n " , __FILE__, __LINE__, __FUNCTION__, assumed.to_string ().c_str ());
245
-
246
215
// ==== 1) bail out early if no tasks are pending ----------------------------
247
216
if (assumed.isEmpty ()) {
248
217
// No tasks in flight, we know no tasks were submitted before this poll
249
218
// was issued, and if we parked here we'd potentially never be woken up.
250
219
// Bail out and return `nil` from `group.next()`.
251
- fprintf (stderr, " [%s:%d] (%s): empty! assumed: %s\n " , __FILE__, __LINE__, __FUNCTION__, assumed.to_string ().c_str ());
252
220
statusRemoveWaiting ();
253
- fprintf (stderr, " [%s:%d] (%s): debug now: %s\n " , __FILE__, __LINE__, __FUNCTION__, statusLoadRelaxed ().to_string ().c_str ());
254
221
result.status = TaskGroup::GroupPollStatus::Empty;
255
222
mutex.unlock (); // TODO: remove group lock, and use status for synchronization
256
223
return result;
@@ -260,8 +227,6 @@ TaskGroup::PollResult TaskGroup::poll(AsyncTask *waitingTask) {
260
227
261
228
// ==== 2) Ready task was polled, return with it immediately -----------------
262
229
if (assumed.readyTasks ()) {
263
- fprintf (stderr, " [%s:%d] (%s): there are ready tasks... %s\n " , __FILE__, __LINE__, __FUNCTION__, statusLoadRelaxed ().to_string ().c_str ());
264
-
265
230
auto assumedStatus = assumed.status ;
266
231
auto newStatus = TaskGroup::GroupStatus{assumedStatus};
267
232
if (status.compare_exchange_weak (
@@ -287,8 +252,6 @@ TaskGroup::PollResult TaskGroup::poll(AsyncTask *waitingTask) {
287
252
// be swift_release'd; we kept it alive while it was in the readyQueue by
288
253
// an additional retain issued as we enqueued it there.
289
254
result.retainedTask = item.getTask ();
290
- fprintf (stderr, " [%s:%d] (%s): about to return: %d\n " , __FILE__, __LINE__, __FUNCTION__, result.retainedTask );
291
-
292
255
switch (item.getStatus ()) {
293
256
case ReadyStatus::Success:
294
257
// Immediately return the polled value
@@ -326,7 +289,6 @@ TaskGroup::PollResult TaskGroup::poll(AsyncTask *waitingTask) {
326
289
waitHead, waitingTask,
327
290
/* success*/ std::memory_order_release,
328
291
/* failure*/ std::memory_order_acquire)) {
329
- fprintf (stderr, " [%s:%d] (%s): added to wait queue\n " , __FILE__, __LINE__, __FUNCTION__);
330
292
mutex.unlock (); // TODO: remove fragment lock, and use status for synchronization
331
293
// no ready tasks, so we must wait.
332
294
result.status = TaskGroup::GroupPollStatus::MustWait;
@@ -358,21 +320,13 @@ void swift::swift_task_group_cancel_all(AsyncTask *task, TaskGroup *group) {
358
320
}
359
321
360
322
bool TaskGroup::cancelAll (AsyncTask *task) {
361
- fprintf (stderr, " [%s:%d] (%s): cancel all child tasks %d\n " , __FILE__, __LINE__, __FUNCTION__, task);
362
-
363
323
// store the cancelled bit
364
324
auto old = statusCancel ();
365
325
if (old.isCancelled ()) {
366
- fprintf (stderr, " [%s:%d] (%s): already was cancelled, group:%d\n " , __FILE__, __LINE__, __FUNCTION__, this );
367
326
// already was cancelled previously, nothing to do?
368
327
return false ;
369
328
}
370
329
371
- // // first time this group is being called cancelAll on, so we must cancel all tasks
372
- // if (this->isEmpty())
373
- // return true;
374
-
375
- fprintf (stderr, " [%s:%d] (%s): calling swift_task_cancel_group_child_tasks, group:%d\n " , __FILE__, __LINE__, __FUNCTION__, this );
376
330
// cancel all existing tasks within the group
377
331
swift_task_cancel_group_child_tasks (task, this );
378
332
return true ;
0 commit comments