apple/swift-nio

NIOLoopBound should get `unchecked` variants that are truly free in release mode

Open

#2,506 opened on Aug 17, 2023

View on GitHub
 (5 comments) (0 reactions) (0 assignees)Swift (749 forks)batch import
good first issuekind/enhancement

Repository metrics

Stars
 (8,453 stars)
PR merge metrics
 (Avg merge 9d 10h) (15 merged PRs in 30d)

Description

NIOLoopBound(Box) is super useful when adopting Sendable but the eventLoop.preconditionInEventLoop() checks everywhere are expensive and -- for repeated accesses -- unnecessary.

There should be unchecked variants of init, get and set value that do eventLoop.assertInEventLoop() instead. Together with @inlinable that should become completely free in release mode (and still check in debug).

Docs:

Contributor guide