worker_thread: Drop process priority when executing low priority work
When executing low priority work, it is a good idea to nice() the
process priority as well so that the executing of the work is truly
run as a low priority work. This decreases the interference the work
might have on the rest of the system.
To achieve this, the work executing loop is rewritten. Instead of
having a loop that always tries to execute the highest priority work,
separate the low priority and high priority handling in separate
loops. This simplifies the logic quite a bit. Furthermore, there is
really no need to convert a low priority worker back to executing high
priority work. When queuing work, a new worker thread is always
spawned whenever a high priority work is queued. Thus, there is no
really any chance a low priority worker could pick up any high
priority work once it has finished low priority work.
Now we no longer can do that as it is not possible to rise a thread
priority back up once it lowered its priority.
The executing logic of the worker thread is thus much simpler now.
Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>