开发者

Infinite loop or repetitive run for daemon

开发者 https://www.devze.com 2023-02-15 15:23 出处:网络
Which is the better to write a \"daemon\" based on oracle schedules: The one that is run once and then is in infinite loop and sleeps for 5 seconds if there is nothing to do (to not waste CPU cycles

Which is the better to write a "daemon" based on oracle schedules:

  1. The one that is run once and then is in infinite loop and sleeps for 5 seconds if there is nothing to do (to not waste CPU cycles).

  2. The one that is started, checked if it is something to 开发者_StackOverflowdo. If not - ends execution and is run after 5 seconds by schedule.

Which one and why do you prefer? Or may be it is some another implementation?


I personally prefer an infinite loop to a scheduled task. With an infinite loop you can see a broader cross-activation overview - Eg You can count number of failures in a row/similar very easily and add error-recovery.

A scheduled task is effectively stateless unless you manually give it state (File/Db/???)


It sounds like you might want to look at using an a queue to do the processing rather than a schedule job. The process can block on the queue waiting for new work.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号