-
Notifications
You must be signed in to change notification settings - Fork 0
/
channelfuture.go
56 lines (45 loc) · 977 Bytes
/
channelfuture.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
package channel
import (
"github.com/kklab-com/goth-kkutil/concurrent"
)
type Future interface {
concurrent.Future
Sync() Future
Completable() concurrent.CompletableFuture
Channel() Channel
_channel() Channel
}
type DefaultFuture struct {
concurrent.Future
channel Channel
}
func NewFuture(channel Channel) Future {
future := &DefaultFuture{
Future: concurrent.NewFuture(nil),
channel: channel,
}
return future
}
func (d *DefaultFuture) AddListener(listener concurrent.FutureListener) concurrent.Future {
return d.Future.AddListener(listener)
}
func (d *DefaultFuture) Sync() Future {
d.Future.Await()
return d
}
func (d *DefaultFuture) Completable() concurrent.CompletableFuture {
return d.Future.(concurrent.CompletableFuture)
}
func (d *DefaultFuture) Channel() Channel {
if !d.IsDone() {
return nil
} else {
if d.IsSuccess() {
return d._channel()
}
}
return nil
}
func (d *DefaultFuture) _channel() Channel {
return d.channel
}