Skip to content

Conversation

@glbrntt
Copy link
Contributor

@glbrntt glbrntt commented Apr 17, 2025

Motivation:

Isolating state to a given event loop is quite a common pattern. These types often provide sendable view APIs which do the event-loop dance for you. Writing these wrappers is somewhat repetitive (each method needs to do the dance) and requires a precondition.

We can make this simpler by providing helper methods on the loop bound types which do the event-loop dance.

Modifications:

Add three methods to NIOLoopBound and NIOLoopBoundBox:

  1. execute to execute a task with the loop bound value on the event loop
  2. submit to execute a task with the loop bound value on the event loop which returns a sendable value
  3. flatSubmit to execute a task with the loop bound value on the event loop which returns a future holding a sendable value

Result:

Easier to build sendable views of non-sendable types which are isolated to a given event loop.

Motivation: Isolating state to a given event loop is quite a common pattern. These types often provide sendable view APIs which do the event-loop dance for you. Writing these wrappers is somewhat repetitive (each method needs to do the dance) and requires a precondition. We can make this simpler by providing helper methods on the loop bound types which do the event-loop dance. Modifications: Add three methods to NIOLoopBound and NIOLoopBoundBox: 1. `execute` to execute a task with the loop bound value on the event loop 2. `submit` to execute a task with the loop bound value on the event loop which returns a sendable value 3. `flatSubmit` to execute a task with the loop bound value on the event loop which returns a future holding a sendable value Result: Easier to build sendable views of non-sendable types which are isolated to a given event loop.
@glbrntt glbrntt added the 🆕 semver/minor Adds new public API. label Apr 17, 2025
@glbrntt glbrntt enabled auto-merge (squash) April 17, 2025 12:41
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.

2 participants