inEventLoop
Returns true
if the current NIOThread
is the same as the NIOThread
that is tied to this EventLoop
. false
otherwise.
var inEventLoop: Bool { get }
This method is intended principally as an optimization point, allowing users to write code that can provide fast-paths when this property is true. It is not suitable as a correctness guard. Code must be correct if this value returns false
even if the event loop context is actually held. That’s because this property is allowed to produce false-negatives
Implementers may implement this method in a way that may produce false-negatives: that is, this value may return false
in cases where the code in question actually is executing on the event loop. It may never produce false positives: this value must never return true
when event loop context is not actually held.
If it is necessary for correctness to confirm that you’re on an event loop, prefer preconditionInEventLoop(file:line:)
.