Skip to content

Actor support for JXFunc #1

@marcprux

Description

@marcprux

@JXFunc handles async function signatures that work with classes but not with actors. You can see this by changing TimePod to extend AnyActor, which (after fixing a couple other trivial issues) will fail (with "Generic parameter 'T' could not be inferred") to build the function:

    @JXFunc var jxsleep = sleep
    public func sleep(duration: TimeInterval) async throws

The reason is that a function reference to a class is (Self)->(Args…)->Result, but an Actor's will be (isolated Self)->(Args…)->Result.

I think this means that every async JXFunc initializer will need to have an additional initializer that accepts Self as isolated, unless some signature massaging can make one of them unnecessary.

    public init<P0>(wrappedValue: @escaping (T) -> (P0) async throws -> R) {
        functionBridge = { FunctionBridge(name: $0, function: wrappedValue) }
    }

    public init<P0>(wrappedValue: @escaping (isolated T) -> (P0) async throws -> R) {
        // TODO…
    }

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