redesigned worker to be more versatile

It is important to be able to execute some code serially just before an
asynchronous task is started and to wrap it's result by some synchronous
code for side effects.

Signed-off-by: Jan Dvořák <mordae@anilinux.org>