Conversation
|
Yeah we can merge this with the modular threads logic 👍 feel free to adjust the worker as you need it |
|
This looks great. That will replace my need for the caddy-supervisor module. |
|
There are still quite a few points open:
I'm trying right now to pass any zval. After looking at how it's done in the parallel extension, we probably need to deep copy the values, though it doesn't have to be quite that complicated. Having a secure mechanism to pass zvals between threads might also be quite nice for extensions in general. We can go ahead with the current state as an initial version and work from there or I can do everything as a big chunk in this PR. |
I'd think that just like in the parallel extension, it might have some of the same issues? Such as trying to pass an exception through? Can we just use the parallel extension to lean on pre-existing code? |
|
Yeah we probably can, C dependencies are just kind of cumbersome to install and hard to test. We could allow passing anything if ext/parallel is installed, but only allow a string otherwise. Easiest way is to just go with strings for now. |
|
Cannot we copy/paste the code (with credits)? It would be better to have a core feature depending on a 3rd-party extension. |
|
I guess the only case where it would make sense to use |
|
Just to clarify again where we go from here:
|
|
Too many conflicts from |
|
I think this would be absolutely gold. Is my understanding correct that it could replace libraries like spatie/async or amphp/parallel but using threads? |
|
No, that would be unrelated. It would be more useful for stuff like queue consumers/workers. But I agree, it would be very nice to have. Currently I still depend on caddy-supervisor to run these things, it would be neat to have this integrated more cleanly. |
|
I'm for supporting this too. This would allow running natively long-running symfony commands such as |
|
Yes this would also enable parallelism by adding a way to wait for task completion. Would also be super nice to restart workers with |
This PR adds a new type of worker thread 'task workers'
caddyfile:
from a regular or worker PHP thread:
inside of the task worker:
Allows:
#1795 is also the reason why this feature is marked as experimental for now. Currently tasks are only passed as strings, but it would theoretically be possible to pass anything, even closures (while keeping thread safety in mind).