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

Make a concrete Thread type that accepts Closure, rather than being extended #78

Open
dktapps opened this issue Aug 15, 2022 · 1 comment

Comments

@dktapps
Copy link
Member

dktapps commented Aug 15, 2022

One of the biggest obstacles to dropping class copying is that we wouldn't be conveniently able to use threads in single-file scripts anymore.
In addition, having to declare a whole class just to run a couple of lines of code is quite annoying and cumbersome.

This would be eased if we could run threads using just closures, similar to ext-parallel. A compatibility layer could then use closures in this manner to preserve backwards compatibility:

$task = new SomeTask();
$worker->stack(fn() => $task->run());

Similar limitations would have to be imposed on the usable closures, like in parallel, such as disallowing declaration of classes.

@dktapps
Copy link
Member Author

dktapps commented Aug 15, 2022

It would probably be best to initially introduce this concept with ClosureThread and ClosureThreadedRunnable, to allow gradual migration.

@dktapps dktapps changed the title Make Thread a concrete type accepting Closure, rather than being extended Make a concrete Thread type that accepts Closure, rather than being extended Aug 15, 2022
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