mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Implement continuations in task-to-thread model.
This is done using a condition variable upon which the awaiting thread will block if the continuation has not be resumed by the point of await. The resuming thread will signal this condition variable, thereby unblocking the awaiting thread. Rdar://99977665
This commit is contained in:
@@ -690,14 +690,28 @@ IRGenModule::IRGenModule(IRGenerator &irgen,
|
||||
*this, "swift.async_task_and_context",
|
||||
{ SwiftTaskPtrTy, SwiftContextPtrTy });
|
||||
|
||||
ContinuationAsyncContextTy = createStructType(
|
||||
*this, "swift.continuation_context",
|
||||
{SwiftContextTy, // AsyncContext header
|
||||
SizeTy, // flags
|
||||
SizeTy, // await synchronization
|
||||
ErrorPtrTy, // error result pointer
|
||||
OpaquePtrTy, // normal result address
|
||||
SwiftExecutorTy}); // resume to executor
|
||||
if (Context.LangOpts.isConcurrencyModelTaskToThread()) {
|
||||
ContinuationAsyncContextTy = createStructType(
|
||||
*this, "swift.continuation_context",
|
||||
{SwiftContextTy, // AsyncContext header
|
||||
SizeTy, // flags
|
||||
SizeTy, // await synchronization
|
||||
ErrorPtrTy, // error result pointer
|
||||
OpaquePtrTy, // normal result address
|
||||
SwiftExecutorTy, // resume to executor
|
||||
SizeTy // pointer to condition variable
|
||||
});
|
||||
} else {
|
||||
ContinuationAsyncContextTy = createStructType(
|
||||
*this, "swift.continuation_context",
|
||||
{SwiftContextTy, // AsyncContext header
|
||||
SizeTy, // flags
|
||||
SizeTy, // await synchronization
|
||||
ErrorPtrTy, // error result pointer
|
||||
OpaquePtrTy, // normal result address
|
||||
SwiftExecutorTy // resume to executor
|
||||
});
|
||||
}
|
||||
ContinuationAsyncContextPtrTy =
|
||||
ContinuationAsyncContextTy->getPointerTo(DefaultAS);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user