MCPcopy Index your code
hub / github.com/codnect/chrono / Schedule

Method Schedule

executor.go:56–79  ·  view source on GitHub ↗
(task Task, delay time.Duration)

Source from the content-addressed store, hash-verified

54}
55
56func (executor *SimpleTaskExecutor) Schedule(task Task, delay time.Duration) (ScheduledTask, error) {
57 if task == nil {
58 return nil, errors.New("task cannot be nil")
59 }
60
61 executor.executorMu.Lock()
62
63 if executor.isShutdown {
64 executor.executorMu.Unlock()
65 return nil, errors.New("no new task won't be accepted because executor is already shut down")
66 }
67
68 executor.nextSequence++
69 scheduledTask, err := CreateScheduledRunnableTask(executor.nextSequence, task, executor.calculateTriggerTime(delay), 0, false)
70 executor.executorMu.Unlock()
71
72 if err != nil {
73 return nil, err
74 }
75
76 executor.addNewTask(scheduledTask)
77
78 return scheduledTask, nil
79}
80
81func (executor *SimpleTaskExecutor) ScheduleWithFixedDelay(task Task, initialDelay time.Duration, delay time.Duration) (ScheduledTask, error) {
82 if task == nil {

Calls 3

calculateTriggerTimeMethod · 0.95
addNewTaskMethod · 0.95