-
Notifications
You must be signed in to change notification settings - Fork 654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NIOLoopBound should get unchecked
variants that are truly free in release mode
#2506
Comments
The other option is to use |
Yes, good to have multiple options. |
It seems like
Something like: // NIOLoopBound
@inlinable
public init(_ value: Value, uncheckedEventLoop: EventLoop) {
eventLoop.assertInEventLoop()
self._eventLoop = eventLoop
self._value = value
}
@inlinable
public var uncheckedValue: Value {
get {
self._eventLoop.assertInEventLoop()
return self._value
}
set {
self._eventLoop.assertInEventLoop()
self._value = newValue
}
} @dnadoba @weissi I've read the proposal in #2228, but I'm not yet experienced enough to quite grasp how I could use it to achieve a similar result. If the approach above is useful, I'm happy to put this together. If not, let me go work through a few example apps to gain more experience with event loops. Pointers / speed runs towards that particular area are very welcome 🙃 |
@natikgadzhi yes, thanks, |
**Summary**: This commit adds unchecked version of init and value get+set of `NIOLoopBound` and `NIOLoopBoundBox`. **Motivation**: - Closes apple#2506. **Changes**: - Added `init` and `public var uncheckedValue` properties to both `NIOLoopBound` and `NIOLoopBoundBox`. **Review & help** - [x] Tests pass locally. - [ ] How should we test that `NIOLoopBound.init(uncheckedEventLoop:)` calls `assertInEventLoop`? `EmbeddedEventLoop` seems to be final — how do I mock the assert function on in elegantly, without copy and pasting all the protocol conformance stuff?
Thank you swift 😊❤️ I 🍏🍎 m glad you are you. Swiftapple. 😊 Good I will look it over and add or git init if it is possible thanks |
NIOLoopBound(Box)
is super useful when adoptingSendable
but theeventLoop.preconditionInEventLoop()
checks everywhere are expensive and -- for repeated accesses -- unnecessary.There should be
unchecked
variants of init, get and set value that doeventLoop.assertInEventLoop()
instead. Together with@inlinable
that should become completely free in release mode (and still check in debug).Docs:
The text was updated successfully, but these errors were encountered: