From 1a4792831419ab384c77889e3020c68c3c797816 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20C=2E=20For=C3=A9s?= Date: Tue, 30 Jul 2024 10:01:34 +0200 Subject: [PATCH] feat(scheduler): does not take any tasks as params --- yotei.go | 3 +-- yotei_test.go | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/yotei.go b/yotei.go index bf4ee84..c2e1324 100644 --- a/yotei.go +++ b/yotei.go @@ -183,7 +183,7 @@ 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 } @@ -191,7 +191,6 @@ func (scheduler *Scheduler) Start(tasks Tasks) { scheduler.mutex.Lock() defer scheduler.mutex.Unlock() - scheduler.tasks = tasks scheduler.quit = make(chan struct{}) scheduler.logger.Info( diff --git a/yotei_test.go b/yotei_test.go index 557aa45..1adce12 100644 --- a/yotei_test.go +++ b/yotei_test.go @@ -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() @@ -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()