File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed
stdlib/public/Concurrency Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -326,15 +326,16 @@ class AsyncTask : public HeapObject, public Job {
326
326
// / fragment.
327
327
static size_t storageOffset (const Metadata *resultType) {
328
328
size_t offset = sizeof (FutureFragment);
329
- size_t alignment = std::max (resultType->vw_alignment (), alignof (void *));
329
+ size_t alignment =
330
+ std::max (resultType->vw_alignment (), alignof (SwiftError *));
330
331
return (offset + alignment - 1 ) & ~(alignment - 1 );
331
332
}
332
333
333
334
// / Determine the size of the future fragment given a particular future
334
335
// / result type.
335
336
static size_t fragmentSize (const Metadata *resultType) {
336
337
return storageOffset (resultType) +
337
- std::max (resultType->vw_size (), sizeof (void *));
338
+ std::max (resultType->vw_size (), sizeof (SwiftError *));
338
339
}
339
340
};
340
341
@@ -463,7 +464,8 @@ class YieldingAsyncContext : public AsyncContext {
463
464
// / task.
464
465
// /
465
466
// / This type matches the ABI of a function `<T> () async throws -> T`, which
466
- // / is used to describe futures.
467
+ // / is the type used by `Task.runDetached` and `Task.group.add` to create
468
+ // / futures.
467
469
class FutureAsyncContext : public AsyncContext {
468
470
public:
469
471
SwiftError *errorResult = nullptr ;
Original file line number Diff line number Diff line change @@ -103,9 +103,6 @@ void AsyncTask::completeFuture(AsyncContext *context, ExecutorRef executor) {
103
103
// Find the next waiting task.
104
104
auto nextWaitingTask = waitingTask->getNextWaitingTask ();
105
105
106
- // Remove this task from the list.
107
- waitingTask->getNextWaitingTask () = nullptr ;
108
-
109
106
// TODO: schedule this task on the executor rather than running it
110
107
// directly.
111
108
waitingTask->run (executor);
@@ -198,7 +195,8 @@ AsyncTaskAndContext swift::swift_task_create_future_f(
198
195
JobFlags flags, AsyncTask *parent, const Metadata *futureResultType,
199
196
AsyncFunctionType<void ()> *function, size_t initialContextSize) {
200
197
assert ((futureResultType != nullptr ) == flags.task_isFuture ());
201
- assert ((futureResultType != nullptr ) == flags.task_isFuture ());
198
+ assert (!flags.task_isFuture () ||
199
+ initialContextSize >= sizeof (FutureAsyncContext));
202
200
assert ((parent != nullptr ) == flags.task_isChildTask ());
203
201
204
202
// Figure out the size of the header.
You can’t perform that action at this time.
0 commit comments