AsyncExecutor(; maxattempts=1, interval=1, delay=0, wait=false)

Handle the asynchronous execution of jobs.


  • maxattempts::UInt64=1: the maximum number of attempts to execute the job.
  • interval::Real=1: the time interval between each attempt to execute the job, in seconds.
  • delay::Real=0: the delay before the first attempt to execute the job, in seconds.
  • wait::Bool=false: determines whether to wait for the job to complete before executing the next task.
Job(core::Thunk; description="", username="")

Create a simple job.


  • core: a Thunk that encloses the job core definition.
  • name: give a short name to the job.
  • description::String="": describe what the job does in more detail.
  • username::String="": indicate who executes the job.


julia> using Thinkers

julia> a = Job(Thunk(sleep, 5); username="me", description="Sleep for 5 seconds");

julia> b = Job(Thunk(run, `pwd` & `ls`); username="me", description="Run some commands");
chain!(x::AbstractJob, y::AbstractJob, z::AbstractJob...)

Chain multiple AbstractJobs one after another.


Return the end time of the job. Return nothing if it has not exited.

execute!(job::AbstractJob, exec::Executor)

Execute a given AbstractJob associated with the Executor.

This function checks if the job has succeeded. If so, it stops immediately. If not, it sleeps for a exec.delay, then runs the job. If exec.maxattempts is more than $1$, it loops over the remaining attempts, sleeping for an exec.interval, running the job, and waiting in each loop.

run!(job::Job; maxattempts=1, interval=1, delay=0, wait=false)
run!(job::Job, worker::Integer; maxattempts=1, interval=1, delay=0, wait=false)

Run a Job with a maximum number of attempts, with each attempt separated by interval seconds and an initial delay in seconds.


Return the start time of the job. Return nothing if it is still pending.


Return the time cost of the job since it started running.

If nothing, the job is still pending. If it is finished, return how long it took to complete.


Get the running result of the job.

The result is wrapped by a Some type. Use something to retrieve its value. If it is nothing, the job is not finished.