General-purpose task scheduler