-
Notifications
You must be signed in to change notification settings - Fork 0
/
type.go
57 lines (53 loc) · 906 Bytes
/
type.go
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package async
import (
"sync"
)
type Thenable interface {
Then(Handler, Handler)
}
type lock struct {
async chan int
ret interface{}
state State
err bool
once *sync.Once
}
type State string
type Handler func(interface{})
type promiseTask func(Handler, Handler)
type CallBack func(interface{}) interface{}
type finallyHandler func()
type AsyncTask func(...interface{}) interface{}
type Tasks []*GoPromise
type Plain []interface{}
type counter struct {
count int
m sync.Mutex
}
type Settled struct {
Status State
Value interface{}
}
type then struct {
success CallBack
fail CallBack
*GoPromise
}
type catch struct {
handler CallBack
*GoPromise
}
type finally struct {
handler finallyHandler
*GoPromise
}
type prototype struct {
*then
*catch
*finally
next *prototype
}
type GoPromise struct {
*lock
*prototype
}