PeaceFounder.Schedulers

PeaceFounder.Schedulers.SchedulerType
mutable struct Scheduler
    condition::Condition
    retry_interval::Union{Int, Nothing}
    delay::Int
    started::Bool
    finished::Bool
    schedule::Vector{Tuple{DateTime, <:Any}}
end

Represents a waitable object which resumes at predetermined scheduled times. A typical use for it is in the event loop like:

scheduler = Scheduler(; retry_interval = 1)

schedule!(scheduler, now() + Second(1), value)

while true
    value = wait(scheduler)
    try
        # Do some stuff
    catch
        retry!(scheduler)
    end
end

In the event loop one manages a state machine which can succed and fail. If it succeds a scheduled time is taken out from the scheduler and proceeds waiting the next event. In the case event at scheduled time had failed the scheduler is notified with retry! method and attempts to run the event loop againafter retry_interval until succeeds.

source
Base.notifyMethod
notify(scheduler::Scheduler[, value])

Notify a scheduler with a value which is returned at wait.

source
Base.waitMethod
wait(scheduler::Scheduler)

Wait until next event is reached and return it's value. In the case event have run through smoothelly the scheduler event is droped with the next wait call. See also retry! method.

source
PeaceFounder.Schedulers.schedule!Method
schedule!(scheduler::Scheduler, timestamp::DateTime[, value])

Schedule an event at timestamp with a provided value.

schedule!(scheduler, now() + Second(1), value)
source