You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using when(first:) without cancelRemaining, the returned Promise is considered a child of all of the input Promises. This means it will prevent cancellation propagation from any other child promises of those inputs. We should see if it's reasonable to "detach" the returned Promise from the input promises after the returned Promise has resolved so e.g. it won't prevent cancellation of any outstanding input promises whose other children have cancelled.
We can't simply propagate cancellation at this point because we don't want to cancel the other inputs if we're the only child.
The text was updated successfully, but these errors were encountered:
Here's a test case that describes the behavior I'm looking for:
func testWhenAllowCancelPropagationForInputsWithoutCancelRemaining(){letsema1=DispatchSemaphore(value:1)letsema2=DispatchSemaphore(value:1)
sema1.wait()
sema2.wait()// Set up 2 input promises, hang another child off of one, have the 2nd resolve first, then// cancel the new child and see if the first propagates cancellation.letnewChild:Promise<Int,String>letpromise:Promise<Int,String>letpromise1CancelExpectation:XCTestExpectationdo{letpromise1=Promise<Int,String>(on:.utility,{(resolver)in
resolver.onRequestCancel(on:.immediate,{(resolver)in
resolver.cancel()})
sema1.wait()
sema1.signal()
resolver.fulfill(with:0xDEADBEEF)})
promise1CancelExpectation =XCTestExpectation(onCancel: promise1)letpromise2=Promise<Int,String>(on:.utility,{(resolver)in
resolver.onRequestCancel(on:.immediate,{(resolver)in
resolver.cancel()})
sema2.wait()
sema2.signal()
resolver.fulfill(with:42)})
promise =when(first:[promise1, promise2], cancelRemaining: false)
newChild = promise1.then(on:.utility,{ $0 })}letexpectation=XCTestExpectation(onSuccess: promise, expectedValue:42)
sema2.signal()wait(for:[expectation], timeout:1)XCTAssertNil(newChild.result)
newChild.requestCancel()wait(for:[promise1CancelExpectation], timeout:1)}
When using
when(first:)
withoutcancelRemaining
, the returned Promise is considered a child of all of the input Promises. This means it will prevent cancellation propagation from any other child promises of those inputs. We should see if it's reasonable to "detach" the returned Promise from the input promises after the returned Promise has resolved so e.g. it won't prevent cancellation of any outstanding input promises whose other children have cancelled.We can't simply propagate cancellation at this point because we don't want to cancel the other inputs if we're the only child.
The text was updated successfully, but these errors were encountered: