Skip to content

Commit 91360f0

Browse files
committed
[Concurrency] Turn "simple task" into just "task".
There isn't a big advantage to keeping "simple" task as a separate concept from a task. Tasks may or may not have futures.
1 parent 0ae6c63 commit 91360f0

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

include/swift/ABI/MetadataKind.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ METADATAKIND(HeapGenericLocalVariable,
8585
METADATAKIND(ErrorObject,
8686
1 | MetadataKindIsNonType | MetadataKindIsRuntimePrivate)
8787

88-
/// A heap-allocated simple task.
89-
METADATAKIND(SimpleTask,
88+
/// A heap-allocated task.
89+
METADATAKIND(Task,
9090
2 | MetadataKindIsNonType | MetadataKindIsRuntimePrivate)
9191

9292
// getEnumeratedMetadataKind assumes that all the enumerated values here

stdlib/public/Concurrency/Task.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,9 @@ void AsyncTask::completeFuture(AsyncContext *context, ExecutorRef executor) {
134134
}
135135

136136
SWIFT_CC(swift)
137-
static void destroySimpleTask(SWIFT_CONTEXT HeapObject *obj) {
137+
static void destroyTask(SWIFT_CONTEXT HeapObject *obj) {
138138
auto task = static_cast<AsyncTask*>(obj);
139139

140-
// FIXME: "Simple task" seems like it's not that useful a concept. We might
141-
// also have task-local storage to destroy.
142-
// assert(!task->isFuture());
143-
144140
// For a future, destroy the result.
145141
if (task->isFuture()) {
146142
task->futureFragment()->destroy();
@@ -155,24 +151,23 @@ static void destroySimpleTask(SWIFT_CONTEXT HeapObject *obj) {
155151
free(task);
156152
}
157153

158-
/// Heap metadata for a simple asynchronous task that does not
159-
/// include a future.
160-
static FullMetadata<HeapMetadata> simpleTaskHeapMetadata = {
154+
/// Heap metadata for an asynchronous task.
155+
static FullMetadata<HeapMetadata> taskHeapMetadata = {
161156
{
162157
{
163-
&destroySimpleTask
158+
&destroyTask
164159
},
165160
{
166161
/*value witness table*/ nullptr
167162
}
168163
},
169164
{
170-
MetadataKind::SimpleTask
165+
MetadataKind::Task
171166
}
172167
};
173168

174169
/// The function that we put in the context of a simple task
175-
/// (one with no future) to handle the final return.
170+
/// to handle the final return.
176171
SWIFT_CC(swift)
177172
static void completeTask(AsyncTask *task, ExecutorRef executor,
178173
AsyncContext *context) {
@@ -254,7 +249,7 @@ AsyncTaskAndContext swift::swift_task_create_future_f(
254249
// Initialize the task so that resuming it will run the given
255250
// function on the initial context.
256251
AsyncTask *task =
257-
new(allocation) AsyncTask(&simpleTaskHeapMetadata, flags,
252+
new(allocation) AsyncTask(&taskHeapMetadata, flags,
258253
function, initialContext);
259254

260255
// Initialize the child fragment if applicable.

0 commit comments

Comments
 (0)