Implementing a cron type scheduler in clojure

前端 未结 3 1127
臣服心动
臣服心动 2021-02-06 03:49

I\'m looking for any way for clojure that can trigger an event at a given time,

For example: I want a particular process to start at 9:30am and then I can trigger anothe

3条回答
  •  南笙
    南笙 (楼主)
    2021-02-06 04:05

    java >=5.0 has the ScheduledExecutorService which covers all this and more. there is a clojure project called at-at which wraps this nicely (and is part of one of my personal favorite projects Overtone)

    you will likely find this other SO question helpful Executing code at regularly timed intervals in Clojure

    from the intoduction:

     The schedule methods create tasks with various delays and return a task object that can be     
     used to cancel or check execution. The scheduleAtFixedRate and scheduleWithFixedDelay   
     methods create and execute tasks that run periodically until cancelled.
    

    Getting cron or at type services right is harder than it sounds, so perhaps using an existing implementation has some advantages over rolling your own.

提交回复
热议问题