Skip to content

Commit

Permalink
feat(scheduler): does not take any tasks as params
Browse files Browse the repository at this point in the history
  • Loading branch information
ConsoleTVs committed Jul 30, 2024
1 parent b79b1b3 commit 1a47928
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 1 addition & 2 deletions yotei.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,14 @@ func (scheduler *Scheduler) worker() {
// If the task list contains no tasks to run (len == 0) no workers will be
// spawned, a warning will be emitted using the [Scheduler.logger] and
// the scheduler will remain in a running state.
func (scheduler *Scheduler) Start(tasks Tasks) {
func (scheduler *Scheduler) Start() {
if scheduler.IsRunning() {
return
}

scheduler.mutex.Lock()
defer scheduler.mutex.Unlock()

scheduler.tasks = tasks
scheduler.quit = make(chan struct{})

scheduler.logger.Info(
Expand Down
6 changes: 4 additions & 2 deletions yotei_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ func TestThreeTasks(t *testing.T) {
Concurrent(),
}

scheduler.Start(tasks)
scheduler.Add(tasks...)
scheduler.Start()
time.Sleep(2 * time.Millisecond)
scheduler.Stop()

Expand Down Expand Up @@ -93,7 +94,8 @@ func TestItDoesNotRunLockedTasks(t *testing.T) {
Lasts(10 * time.Millisecond),
}

scheduler.Start(tasks)
scheduler.Add(tasks...)
scheduler.Start()
time.Sleep(100 * time.Millisecond)
scheduler.Stop()

Expand Down

0 comments on commit 1a47928

Please sign in to comment.