You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
It would probably be best to initially introduce this concept with ClosureThread and ClosureThreadedRunnable, to allow gradual migration.
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
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:
Similar limitations would have to be imposed on the usable closures, like in parallel, such as disallowing declaration of classes.
The text was updated successfully, but these errors were encountered: