Nukesor / pueue

:stars: Manage your shell commands.
MIT License
4.68k stars 128 forks source link

Refactor Process State handling #548

Closed Nukesor closed 1 week ago

Nukesor commented 1 week ago

Problem

Right now, the TaskHandler that supervises the handles for all subprocesses runs in one thread while the API handlers for the client run in their own threads. The process handles are currently bound to the TaskHandler's memory and not directly visible to the message handlers.

Due to the limitation of this design, any client commands that directly affect a process, such as pueue add --immediate, need to be forwarded via mpsc channel to the TaskHandler, as the message handlers have no access to the process handles.

This results in a short delay for such actions, which becomes a problem when scripting Pueue and also when writing tests.

Solutions

There're two approaches to solve this problem:

In general, I would really like to only have a single mutex to prevent deadlocks, so if it's viable, I would prefer the first solution.

Tasks: