Skip to content
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

Actor support for JXFunc #1

Open
marcprux opened this issue Dec 5, 2022 · 0 comments
Open

Actor support for JXFunc #1

marcprux opened this issue Dec 5, 2022 · 0 comments

Comments

@marcprux
Copy link
Member

marcprux commented Dec 5, 2022

@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…
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant