File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed
Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -37,14 +37,26 @@ actor DatabasePool {
3737 var availableDatabases : Set < DatabaseInfo > = . init( )
3838
3939 func setUp( ) async throws {
40- for _ in ( 0 ..< maxCount) {
41- availableDatabases. insert ( try await launchDB ( ) )
40+ try await withThrowingTaskGroup ( of: DatabaseInfo . self) { group in
41+ for _ in ( 0 ..< maxCount) {
42+ group. addTask {
43+ try await self . launchDB ( )
44+ }
45+ }
46+ for try await info in group {
47+ availableDatabases. insert ( info)
48+ }
4249 }
4350 }
4451
4552 func tearDown( ) async throws {
46- for dbInfo in availableDatabases {
47- try await removeDB ( dbInfo: dbInfo)
53+ try await withThrowingTaskGroup { group in
54+ for dbInfo in availableDatabases {
55+ group. addTask {
56+ try await self . removeDB ( dbInfo: dbInfo)
57+ }
58+ }
59+ try await group. waitForAll ( )
4860 }
4961 }
5062
You can’t perform that action at this time.
0 commit comments