Skip to content

Commit 871efc7

Browse files
[Runtime] Use swiftasync + tail calls correctly in runtime unittests.
1 parent 67bcb66 commit 871efc7

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

unittests/runtime/Actor.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class TaskContinuationFromLambda {
119119

120120
SWIFT_CC(swiftasync)
121121
static void invoke(SWIFT_ASYNC_CONTEXT AsyncContext *context, SWIFT_CONTEXT HeapObject *) {
122-
(*lambdaStorage)(static_cast<Context*>(context));
122+
return (*lambdaStorage)(static_cast<Context*>(context));
123123
}
124124

125125
public:
@@ -219,20 +219,20 @@ static AsyncTask *createTaskStoring(JobPriority priority,
219219
TEST(ActorTest, validateTestHarness) {
220220
run([] {
221221
auto task0 = createTask(JobPriority::Background,
222-
[](AsyncContext *context) {
222+
[](AsyncContext *context) SWIFT_CC(swiftasync) {
223223
EXPECT_PROGRESS(5);
224224
EXPECT_PROGRESS(6);
225225
finishTest();
226226
return context->ResumeParent(context);
227227
});
228228
auto task1 = createTask(JobPriority::Default,
229-
[](AsyncContext *context) {
229+
[](AsyncContext *context) SWIFT_CC(swiftasync) {
230230
EXPECT_PROGRESS(1);
231231
EXPECT_PROGRESS(2);
232232
return context->ResumeParent(context);
233233
});
234234
auto task2 = createTask(JobPriority::Default,
235-
[](AsyncContext *context) {
235+
[](AsyncContext *context) SWIFT_CC(swiftasync) {
236236
EXPECT_PROGRESS(3);
237237
EXPECT_PROGRESS(4);
238238
return context->ResumeParent(context);
@@ -253,22 +253,22 @@ TEST(ActorTest, actorSwitch) {
253253
auto actor = createActor();
254254
auto task0 = createTaskStoring(JobPriority::Default,
255255
(AsyncTask*) nullptr, actor,
256-
[](Context *context) {
256+
[](Context *context) SWIFT_CC(swiftasync) {
257257
EXPECT_PROGRESS(1);
258258
EXPECT_TRUE(swift_task_getCurrentExecutor().isGeneric());
259259
EXPECT_EQ(nullptr, context->get<0>());
260260
std::get<0>(context->values) = swift_task_getCurrent();
261261

262262
auto continuation = prepareContinuation<Context>(
263-
[](Context *context) {
263+
[](Context *context) SWIFT_CC(swiftasync) {
264264
EXPECT_PROGRESS(2);
265265
auto executor = swift_task_getCurrentExecutor();
266266
EXPECT_FALSE(executor.isGeneric());
267267
EXPECT_EQ(ExecutorRef::forDefaultActor(context->get<1>()),
268268
executor);
269269
EXPECT_EQ(swift_task_getCurrent(), context->get<0>());
270270
auto continuation = prepareContinuation<Context>(
271-
[](Context *context) {
271+
[](Context *context) SWIFT_CC(swiftasync) {
272272
EXPECT_PROGRESS(3);
273273
EXPECT_TRUE(swift_task_getCurrentExecutor().isGeneric());
274274
EXPECT_EQ(swift_task_getCurrent(), context->get<0>());
@@ -295,7 +295,7 @@ TEST(ActorTest, actorContention) {
295295

296296
auto task0 = createTaskStoring(JobPriority::Default,
297297
(AsyncTask*) nullptr, actor,
298-
[](Context *context) {
298+
[](Context *context) SWIFT_CC(swiftasync) {
299299
EXPECT_PROGRESS(1);
300300
EXPECT_TRUE(swift_task_getCurrentExecutor().isGeneric());
301301
EXPECT_EQ(nullptr, context->get<0>());
@@ -304,7 +304,7 @@ TEST(ActorTest, actorContention) {
304304
std::get<0>(context->values) = task;
305305

306306
parkTask(task, context,
307-
[](Context *context) {
307+
[](Context *context) SWIFT_CC(swiftasync) {
308308
EXPECT_PROGRESS(3);
309309
auto executor = swift_task_getCurrentExecutor();
310310
EXPECT_FALSE(executor.isGeneric());
@@ -313,7 +313,7 @@ TEST(ActorTest, actorContention) {
313313
auto task = swift_task_getCurrent();
314314
EXPECT_EQ(task, context->get<0>());
315315
parkTask(task, context,
316-
[](Context *context) {
316+
[](Context *context) SWIFT_CC(swiftasync) {
317317
EXPECT_PROGRESS(4);
318318
EXPECT_TRUE(swift_task_getCurrentExecutor().isGeneric());
319319
EXPECT_EQ(swift_task_getCurrent(), context->get<0>());
@@ -328,7 +328,7 @@ TEST(ActorTest, actorContention) {
328328

329329
auto task1 = createTaskStoring(JobPriority::Background,
330330
(AsyncTask*) nullptr, actor,
331-
[](Context *context) {
331+
[](Context *context) SWIFT_CC(swiftasync) {
332332
EXPECT_PROGRESS(2);
333333
auto executor = swift_task_getCurrentExecutor();
334334
EXPECT_FALSE(executor.isGeneric());
@@ -339,7 +339,7 @@ TEST(ActorTest, actorContention) {
339339
std::get<0>(context->values) = task;
340340

341341
parkTask(task, context,
342-
[](Context *context) {
342+
[](Context *context) SWIFT_CC(swiftasync) {
343343
EXPECT_PROGRESS(5);
344344
EXPECT_TRUE(swift_task_getCurrentExecutor().isGeneric());
345345
EXPECT_EQ(swift_task_getCurrent(), context->get<0>());

unittests/runtime/TaskStatus.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static void simpleTaskInvokeFunction(SWIFT_ASYNC_CONTEXT AsyncContext *context,
4848
// Return to finish off the task.
4949
// In a normal situation we'd need to free the context, but here
5050
// we know we're at the top level.
51-
valueContext->ResumeParent(valueContext);
51+
return valueContext->ResumeParent(valueContext);
5252
}
5353

5454
template <class T>

0 commit comments

Comments
 (0)