Skip to content

Conversation

@rnro
Copy link
Contributor

@rnro rnro commented Feb 13, 2025

Motivation:

Whilst working on the NIOHTTP1 strict concurrency work I encountered a few gaps in the API where I needed isolated analogues of methods on futures.

Modifications:

  • Add makeSucceededIsolatedFuture
  • Add a new internal initializer for EventLoopFuture which does not require the value to be Sendable for use in isolated contexts.
  • Add a variant of flatMapError which can handle closures which return isolated futures
  • Add a futureResult computed property which allows us to avoid the otherwise clumsy future.nonIsolated().futureResult.assumeIsolated()

Result:

More ability to work with isolated futures.

Motivation:

Whilst working on the NIOHTTP1 strict concurrency work I encountered a
few gaps in the API where I needed isolated analogues of methods on futures.

Modifications:

* Add `makeSucceededIsolatedFuture`
* Add a new internal initializer for `EventLoopFuture` which does not
  require the value to be Sendable for use in isolated contexts.
* Add a variant of `flatMapError` which can handle closures which return
  isolated futures
* Add a `futureResult` computed property which allows us to avoid the
  otherwise clumsy `future.nonIsolated().futureResult.assumeIsolated()`

Result:

More ability to work with isolated futures.
@Lukasa Lukasa added the 🆕 semver/minor Adds new public API. label Feb 13, 2025
Copy link
Contributor

@Lukasa Lukasa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically looking good, a few notes.

}

@usableFromInline
var futureResult: EventLoopFuture<Value>.Isolated {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you've added this, we may as well make it public and inlinable.

@rnro rnro requested a review from Lukasa February 14, 2025 10:18
@rnro rnro merged commit 7789652 into apple:main Feb 14, 2025
32 of 35 checks passed
@rnro rnro deleted the more_isolated_api branch February 14, 2025 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🆕 semver/minor Adds new public API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants