-
Notifications
You must be signed in to change notification settings - Fork 2
/
Async.go
156 lines (143 loc) · 3.53 KB
/
Async.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
// This code is transcompiled by LuneScript.
package lnsc
import . "github.com/ifritJP/LuneScript/src/lune/base/runtime_go"
var init_Async bool
var Async__mod__ string
// declaration Class -- PipeItem
type Async_PipeItemMtd interface {
Get_item() LnsAny
}
type Async_PipeItem struct {
item LnsAny
FP Async_PipeItemMtd
}
func Async_PipeItem2Stem( obj LnsAny ) LnsAny {
if obj == nil {
return nil
}
return obj.(*Async_PipeItem).FP
}
type Async_PipeItemDownCast interface {
ToAsync_PipeItem() *Async_PipeItem
}
func Async_PipeItemDownCastF( multi ...LnsAny ) LnsAny {
if len( multi ) == 0 { return nil }
obj := multi[ 0 ]
if ddd, ok := multi[ 0 ].([]LnsAny); ok { obj = ddd[0] }
work, ok := obj.(Async_PipeItemDownCast)
if ok { return work.ToAsync_PipeItem() }
return nil
}
func (obj *Async_PipeItem) ToAsync_PipeItem() *Async_PipeItem {
return obj
}
func NewAsync_PipeItem(arg1 LnsAny) *Async_PipeItem {
obj := &Async_PipeItem{}
obj.FP = obj
obj.InitAsync_PipeItem(arg1)
return obj
}
func (self *Async_PipeItem) InitAsync_PipeItem(arg1 LnsAny) {
self.item = arg1
}
func (self *Async_PipeItem) Get_item() LnsAny{ return self.item }
// declaration Class -- Pipe
type Async_PipeMtd interface {
Access() LnsAny
GetNext() LnsAny
Loop()
Start()
}
type Async_Pipe struct {
LnsThread
pipe LnsAny
started bool
FP Async_PipeMtd
}
func Async_Pipe2Stem( obj LnsAny ) LnsAny {
if obj == nil {
return nil
}
return obj.(*Async_Pipe).FP
}
type Async_PipeDownCast interface {
ToAsync_Pipe() *Async_Pipe
}
func Async_PipeDownCastF( multi ...LnsAny ) LnsAny {
if len( multi ) == 0 { return nil }
obj := multi[ 0 ]
if ddd, ok := multi[ 0 ].([]LnsAny); ok { obj = ddd[0] }
work, ok := obj.(Async_PipeDownCast)
if ok { return work.ToAsync_Pipe() }
return nil
}
func (obj *Async_Pipe) ToAsync_Pipe() *Async_Pipe {
return obj
}
// 35: DeclConstr
func (self *Async_Pipe) InitAsync_Pipe(pipe LnsAny) {
self.InitLnsThread()
self.pipe = pipe
self.started = false
}
// 43: decl @lune.@base.@Async.Pipe.getNext
func (self *Async_Pipe) GetNext() LnsAny {
if self.started{
{
_pipe := self.pipe
if _pipe != nil {
pipe := _pipe.(*Lns__pipe)
var val LnsAny
{
_val := pipe.FP.Get()
if _val == nil{
return nil
} else {
val = _val
}
}
return NewAsync_PipeItem(val)
}
}
}
return self.FP.Access()
}
// 55: decl @lune.@base.@Async.Pipe.loop
func (self *Async_Pipe) Loop() {
var pipe *Lns__pipe
{
_pipe := self.pipe
if _pipe == nil{
return
} else {
pipe = _pipe.(*Lns__pipe)
}
}
for {
var val *Async_PipeItem
{
_val := self.FP.Access()
if _val == nil{
pipe.FP.Put(nil)
break
} else {
val = _val.(*Async_PipeItem)
}
}
pipe.FP.Put(val.FP.Get_item())
}
}
// 67: decl @lune.@base.@Async.Pipe.start
func (self *Async_Pipe) Start() {
self.started = true
go self.FP.Loop()
}
func Lns_Async_init() {
if init_Async { return }
init_Async = true
Async__mod__ = "@lune.@base.@Async"
Lns_InitMod()
}
func init() {
init_Async = false
}