Skip to content

Commit

Permalink
Introduce assumeIsolated() methods on EventLoop, `EventLoopPromis…
Browse files Browse the repository at this point in the history
…e` and `EventLoopFuture`

> All methods/types are currently `internal` so we don't have to bikeshed just yet but we can move forward to get `NIOCore` warning free under strict concurrency

# Motivation

Methods on the above types are often called from the same event loop; however, we cannot prove to the compiler that this is true so we had to mark many methods on those types with `@Sendable` or require the generic type to be `Sendable`. This leads to unnecessary usage of `NIOLoopBound` when instead we should just dynamically assert that we are on the event loop. @dnadoba opened a very similar PR #2228.

# Modification

This PR provides a method called `assumeIsolated()` on the three types that returns a type which re-declaration of all methods of the wrapped typed that have `Sendable` annotations. This new type is asserting at runtime that we are on the right event loop; hence, we don't need a `Sendable` value.

# Result

This PR makes it easier for our adopters to avoid newly introduced `Sendable` warnings
  • Loading branch information
FranzBusch committed Feb 19, 2024
1 parent 0fbf6f1 commit e66cdbb
Show file tree
Hide file tree
Showing 2 changed files with 505 additions and 1 deletion.
Loading

0 comments on commit e66cdbb

Please sign in to comment.