-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscheduler.go
More file actions
43 lines (30 loc) · 786 Bytes
/
scheduler.go
File metadata and controls
43 lines (30 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright 2017 Granitic. All rights reserved.
// Use of this source code is governed by an Apache 2.0 license that can be found in the LICENSE file at the root of this project.
package timer
type SimpleScheduler struct {
dispatcher Dispatcher
}
func NewSimpleScheduler(dispatcher Dispatcher) Scheduler {
return &SimpleScheduler{
dispatcher: dispatcher,
}
}
func (s *SimpleScheduler) Start() {
s.dispatcher.Start()
}
func (s *SimpleScheduler) Stop() {
s.dispatcher.Stop()
}
func (s *SimpleScheduler) Schedule(fn func()) {
s.dispatcher.Dispatch(fn)
}
type EmptyScheduler struct{}
func NewEmptyScheduler() Scheduler {
return &EmptyScheduler{}
}
func (e *EmptyScheduler) Start() {
}
func (e *EmptyScheduler) Stop() {
}
func (e *EmptyScheduler) Schedule(func()) {
}