Skip to content

Give NIOLoopBoundBox a sending off-EL initialiser once compiler is ready #2754

Open
@weissi

Description

@weissi

https://github.com/swiftlang/swift-evolution/blob/main/proposals/0430-transferring-parameters-and-results.md will be useful to construct NIOLoopBoundBox with a non-Sendable value off EL.

But the compiler isn't ready quite yet.

This is a followup for #2753 (which allows Sendable values)

#if compiler(>=6.0) // `sending` is >= 6.0
extension NIOLoopBoundBox {
    /// Initialise a ``NIOLoopBoundBox`` by `sending` (i.e. transferring) a value, validly callable off `eventLoop`.
    ///
    /// Contrary to ``init(_:eventLoop:)``, this method can be called off `eventLoop` because we are `sending` the value across the isolation domain.
    /// Because we're `sending` `value`, we just need to protect it against mutations (because nothing else can have access to it anymore).
    public static func makeBoxSendingValue(
        _ value: sending Value,
        as: Value.Type = Value.self,
        eventLoop: EventLoop
    ) -> NIOLoopBoundBox<Value> {
        ...
    }
}
#endif

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions