mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
DiscardingTaskGroup now shares some implementation with "Accumulating" TaskGroup
This commit is contained in:
@@ -54,6 +54,14 @@ public:
|
||||
|
||||
// Provide accessor for task group's status record
|
||||
TaskGroupTaskStatusRecord *getTaskRecord();
|
||||
|
||||
/// The group is a `TaskGroup` that accumulates results.
|
||||
bool isAccumulatingResults() {
|
||||
return !isDiscardingResults();
|
||||
}
|
||||
|
||||
/// The group is a `DiscardingTaskGroup` that discards results.
|
||||
bool isDiscardingResults();
|
||||
};
|
||||
|
||||
} // end namespace swift
|
||||
|
||||
@@ -289,16 +289,6 @@ void swift_taskGroup_cancelAll(TaskGroup *group);
|
||||
SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift)
|
||||
bool swift_taskGroup_isCancelled(TaskGroup *group);
|
||||
|
||||
/// Check if the task group is discarding results or not.
|
||||
///
|
||||
/// This can be called from any thread. Its Swift signature is
|
||||
///
|
||||
/// \code
|
||||
/// func swift_taskGroup_isDiscardingResults(group: Builtin.RawPointer)
|
||||
/// \endcode
|
||||
SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift)
|
||||
bool swift_taskGroup_isDiscardingResults(TaskGroup *group);
|
||||
|
||||
/// Wait until all pending tasks from the task group have completed.
|
||||
/// If this task group is accumulating results, this also discards all those results.
|
||||
///
|
||||
|
||||
@@ -273,10 +273,6 @@ OVERRIDE_TASK_GROUP(taskGroup_isCancelled, bool,
|
||||
SWIFT_EXPORT_FROM(swift_Concurrency), SWIFT_CC(swift),
|
||||
swift::, (TaskGroup *group), (group))
|
||||
|
||||
OVERRIDE_TASK_GROUP(taskGroup_isDiscardingResults, bool,
|
||||
SWIFT_EXPORT_FROM(swift_Concurrency), SWIFT_CC(swift),
|
||||
swift::, (TaskGroup *group), (group))
|
||||
|
||||
OVERRIDE_TASK_GROUP(taskGroup_wait_all, void,
|
||||
SWIFT_EXPORT_FROM(swift_Concurrency), SWIFT_CC(swiftasync),
|
||||
swift::,
|
||||
|
||||
@@ -465,7 +465,7 @@ static TaskGroup *asAbstract(TaskGroupImpl *group) {
|
||||
return reinterpret_cast<TaskGroup*>(group);
|
||||
}
|
||||
|
||||
TaskGroupTaskStatusRecord * TaskGroup::getTaskRecord() {
|
||||
TaskGroupTaskStatusRecord *TaskGroup::getTaskRecord() {
|
||||
return asImpl(this)->getTaskRecord();
|
||||
}
|
||||
|
||||
|
||||
@@ -307,10 +307,6 @@ OVERRIDE_TASK_GROUP(taskGroup_isCancelled, bool,
|
||||
SWIFT_EXPORT_FROM(swift_Concurrency), SWIFT_CC(swift),
|
||||
swift::, (TaskGroup *group), (group))
|
||||
|
||||
OVERRIDE_TASK_GROUP(taskGroup_isDiscardingResults, bool,
|
||||
SWIFT_EXPORT_FROM(swift_Concurrency), SWIFT_CC(swift),
|
||||
swift::, (TaskGroup *group), (group))
|
||||
|
||||
OVERRIDE_TASK_GROUP(taskGroup_cancelAll, void,
|
||||
SWIFT_EXPORT_FROM(swift_Concurrency), SWIFT_CC(swift),
|
||||
swift::, (TaskGroup *group), (group))
|
||||
|
||||
@@ -552,7 +552,3 @@ func _taskGroupWaitAll<T>(
|
||||
group: Builtin.RawPointer,
|
||||
bodyError: Error?
|
||||
) async throws -> T?
|
||||
|
||||
@available(SwiftStdlib 5.8, *) // FIXME: remove
|
||||
@_silgen_name("swift_taskGroup_isDiscardingResults")
|
||||
func _taskGroupIsDiscardingResults(group: Builtin.RawPointer) -> Bool
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -140,7 +140,7 @@ func test_discardingTaskGroup_automaticallyRethrows_first_withThrowingBodyFirst(
|
||||
throw bodyError
|
||||
}
|
||||
|
||||
print("Expected error to be thrown")
|
||||
fatalError("Expected error to be thrown")
|
||||
} catch {
|
||||
// CHECK: Throwing: Boom(id: "body, first, isCancelled:false
|
||||
// CHECK: Throwing: Boom(id: "task, second, isCancelled:true
|
||||
@@ -167,7 +167,7 @@ func test_discardingTaskGroup_automaticallyRethrows_first_withThrowingBodySecond
|
||||
throw bodyError
|
||||
}
|
||||
|
||||
print("Expected error to be thrown")
|
||||
fatalError("Expected error to be thrown")
|
||||
} catch {
|
||||
// CHECK: Throwing: Boom(id: "task, first, isCancelled:false
|
||||
// CHECK: Throwing: Boom(id: "body, second, isCancelled:true
|
||||
|
||||
@@ -219,10 +219,6 @@ TEST_F(CompatibilityOverrideConcurrencyTest, test_swift_taskGroup_waitAll) {
|
||||
swift_taskGroup_waitAll(nullptr, nullptr, nullptr, nullptr, nullptr, nullptr);
|
||||
}
|
||||
|
||||
TEST_F(CompatibilityOverrideConcurrencyTest, test_swift_taskGroup_isDiscardingResults) {
|
||||
swift_taskGroup_isDiscardingResults(nullptr);
|
||||
}
|
||||
|
||||
TEST_F(CompatibilityOverrideConcurrencyTest, test_swift_taskGroup_addPending) {
|
||||
swift_taskGroup_addPending(nullptr, true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user