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

Improve usability of the Spawn trait #311

Open
Thomasdezeeuw opened this issue Oct 22, 2020 · 2 comments · May be fixed by #634
Open

Improve usability of the Spawn trait #311

Thomasdezeeuw opened this issue Oct 22, 2020 · 2 comments · May be fixed by #634
Labels
enhancement An improvement of the API. priority:low Low priority issue.

Comments

@Thomasdezeeuw
Copy link
Owner

Thomasdezeeuw commented Oct 22, 2020

In commit c33ed02 (issue #279) a new Spawn trait was introduced. It comes with three generic parameters S (Supervisor), NA (NewActor) and RT (either ThreadLocal or ThreadSafe). This was required because spawn of thread-safe actors requires, S, NA and NA::Actor to be Send + Sync, while thread-local actors don't have this requirement. However when using async function as actor we can't name NA or NA::Actor, making this trait impossible to use with it.

My initial idea was to split the two traits: Spawn and SpawnLocal, but types like TcpServer need a single trait otherwise we have to implement that twice as well.

@Thomasdezeeuw Thomasdezeeuw added the enhancement An improvement of the API. label Oct 22, 2020
@Thomasdezeeuw
Copy link
Owner Author

Some context: Spawn should be able to be used in functions that start actors. For example:

fn start_my_actor<S>(spawn: S)
where
    S: Spawn<MySupervisor, MyActor, ThreadLocal>
{
    // ...
}

The problem here is that MyActor for asynchronous function can't be named. MySupervisor is also a bit hard when using a regular function.

@Thomasdezeeuw
Copy link
Owner Author

In pr #433 I reviewed the trait again, but I didn't see any to move the S and NA parameters to the methods. Punting this until after the first release.

@Thomasdezeeuw Thomasdezeeuw removed this from the First release milestone Mar 26, 2021
@Thomasdezeeuw Thomasdezeeuw linked a pull request Apr 29, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement of the API. priority:low Low priority issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant