]> git.giacomolli.uk - onechat/blobdiff - schedule.go
Reflow comments over the reflow width
[onechat] / schedule.go
index b3a65ea94193a6431693313ca6f5833d836ccefb..28a5a767777bd341e880b046dde2fac9e8d7f675 100644 (file)
@@ -33,10 +33,10 @@ const (
        // scheduleSource is the source of the work events of the runs.
        scheduleSource = "schedule"
 
        // scheduleSource is the source of the work events of the runs.
        scheduleSource = "schedule"
 
-       // scheduleCheck is the longest wait of Run before it looks at the times
-       // again, so that it sees a suspend of the machine or a change of the
-       // clock.
-       scheduleCheck = time.Minute
+       // scheduleClockWaitTimeout is the longest wait of Run before it looks
+       // at the times again, so that it sees a suspend of the machine or a
+       // change of the clock.
+       scheduleClockWaitTimeout = time.Minute
 
        // scheduleLate is how long after its time a run is late.
        scheduleLate = time.Minute
 
        // scheduleLate is how long after its time a run is late.
        scheduleLate = time.Minute
@@ -58,7 +58,6 @@ func openSchedules(path, owner string, clock func() time.Time, logger *slog.Logg
                owner:   owner,
                clock:   clock,
                logger:  logger,
                owner:   owner,
                clock:   clock,
                logger:  logger,
-               check:   scheduleCheck,
                changed: make(chan struct{}, 1),
        }
 
                changed: make(chan struct{}, 1),
        }
 
@@ -118,7 +117,6 @@ type Schedules struct {
        owner   string
        clock   func() time.Time
        logger  *slog.Logger
        owner   string
        clock   func() time.Time
        logger  *slog.Logger
-       check   time.Duration
        changed chan struct{}
 
        mutex sync.Mutex
        changed chan struct{}
 
        mutex sync.Mutex
@@ -126,9 +124,10 @@ type Schedules struct {
 }
 
 // Run starts the runs of the due schedules in l until ctx ends. It waits until
 }
 
 // Run starts the runs of the due schedules in l until ctx ends. It waits until
-// the first due time, at most check at a time, and also wakes at a set or a
-// remove. So a schedule that came due while the daemon was stopped runs at the
-// start. It returns the error of a write of the log or of the file.
+// the first due time, at most scheduleClockWaitTimeout at a time, and also
+// wakes at a set or a remove. So a schedule that came due while the daemon was
+// stopped runs at the start. It returns the error of a write of the log or of
+// the file.
 func (s *Schedules) Run(ctx context.Context, l *TurnLoop) error {
        for {
                err := s.deliver(ctx, l)
 func (s *Schedules) Run(ctx context.Context, l *TurnLoop) error {
        for {
                err := s.deliver(ctx, l)
@@ -143,7 +142,7 @@ func (s *Schedules) Run(ctx context.Context, l *TurnLoop) error {
 
                wait, found := s.Wait(s.clock())
                if found {
 
                wait, found := s.Wait(s.clock())
                if found {
-                       timer = time.NewTimer(min(wait, s.check))
+                       timer = time.NewTimer(min(wait, scheduleClockWaitTimeout))
                        timeout = timer.C
                }
 
                        timeout = timer.C
                }