@@ -64,6 +64,7 @@ module System.Hworker
6464 , createWith
6565 , destroy
6666 , worker
67+ , scheduler
6768 , monitor
6869 -- * Queuing Jobs
6970 , queue
@@ -837,15 +838,12 @@ worker hw =
837838 delayAndRun
838839
839840
840- -- | Start a monitor. Like 'worker', this is blocking, so should be
841- -- started in a thread. This is responsible for retrying jobs that
842- -- time out (which can happen if the processing thread is killed, for
843- -- example) and for pushing scheduled jobs to the queue at the expected time.
844- -- You need to have at least one of these running to have
845- -- the retry happen, but it is safe to have any number running.
841+ -- | Start a scheduler. Like 'worker', this is blocking, so should be
842+ -- started in a thread. This is responsible for pushing scheduled jobs
843+ -- to the queue at the expected time.
846844
847- monitor :: Job s t => Hworker s t -> IO ()
848- monitor hw =
845+ scheduler :: Job s t => Hworker s t -> IO ()
846+ scheduler hw =
849847 forever $ do
850848 now <- getCurrentTime
851849
@@ -868,6 +866,20 @@ monitor hw =
868866 Left err ->
869867 liftIO $ hwlog hw err
870868
869+ threadDelay 500000 >> scheduler hw
870+
871+
872+ -- | Start a monitor. Like 'worker', this is blocking, so should be
873+ -- started in a thread. This is responsible for retrying jobs that
874+ -- time out (which can happen if the processing thread is killed, for
875+ -- example). You need to have at least one of these running to have
876+ -- the retry happen, but it is safe to have any number running.
877+
878+ monitor :: Job s t => Hworker s t -> IO ()
879+ monitor hw =
880+ forever $ do
881+ now <- getCurrentTime
882+
871883 runWithList hw (R. hkeys (progressQueue hw)) $ \ js ->
872884 forM_ js $ \ j ->
873885 runWithMaybe hw (R. hget (progressQueue hw) j) $
0 commit comments