-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitc.go
More file actions
36 lines (29 loc) · 725 Bytes
/
gitc.go
File metadata and controls
36 lines (29 loc) · 725 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
package gitc
import (
"sync"
)
// Global dispatcher
var (
GlobalDispatcher *Dispatcher
once sync.Once
)
// Initialize the dispatcher once
func init() {
once.Do(func() {
GlobalDispatcher = NewDispatcher()
})
}
/* wrappers for Dispatcher singleton */
func StartTask(name string, handler TaskHandler, mailboxSize int) error {
return GlobalDispatcher.StartTask(name, handler, mailboxSize)
}
func Send(from, to string, messageType MessageType, payload interface{}) error {
return GlobalDispatcher.Send(from, to, messageType, payload)
}
func StopTask(name string) error {
return GlobalDispatcher.StopTask(name)
}
func ResetDispatcher() {
GlobalDispatcher.Reset()
GlobalDispatcher = NewDispatcher()
}