mirror of
https://github.com/bloeys/cogo.git
synced 2025-12-29 08:58:19 +00:00
Embed out in coroutine+YieldTo+Yielder interface+Sleeper
This commit is contained in:
94
demo.cogo.go
Executable file
94
demo.cogo.go
Executable file
@ -0,0 +1,94 @@
|
||||
// Code generated by 'cogo'; DO NOT EDIT.
|
||||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/bloeys/cogo/cogo"
|
||||
)
|
||||
|
||||
func test_cogo(c *cogo.Coroutine[int, int]) {
|
||||
switch c.State {
|
||||
case 0:
|
||||
switch c.SubState {
|
||||
default:
|
||||
}
|
||||
|
||||
println("test yield:", 1)
|
||||
c.State++
|
||||
c.SubState = -1
|
||||
c.Out = 1
|
||||
return
|
||||
case 1:
|
||||
switch c.SubState {
|
||||
default:
|
||||
}
|
||||
c.State++
|
||||
c.SubState = -1
|
||||
c.Yielder = cogo.NewSleeper(100 * time.Millisecond)
|
||||
return
|
||||
case 2:
|
||||
switch c.SubState {
|
||||
default:
|
||||
}
|
||||
c.State++
|
||||
c.SubState = -1
|
||||
c.Yielder = cogo.New(test2, 0)
|
||||
return
|
||||
case 3:
|
||||
switch c.SubState {
|
||||
default:
|
||||
}
|
||||
|
||||
println("test yield:", 2)
|
||||
c.State++
|
||||
c.SubState = -1
|
||||
c.Out = 2
|
||||
return
|
||||
case 4:
|
||||
switch c.SubState {
|
||||
default:
|
||||
}
|
||||
c.State = -1
|
||||
c.SubState = -1
|
||||
default:
|
||||
c.State = -1
|
||||
c.SubState = -1
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func test2_cogo(c *cogo.Coroutine[int, int]) {
|
||||
switch c.State {
|
||||
case 0:
|
||||
switch c.SubState {
|
||||
default:
|
||||
}
|
||||
|
||||
println("test2222 yield:", 1)
|
||||
c.State++
|
||||
c.SubState = -1
|
||||
c.Out = 1
|
||||
return
|
||||
case 1:
|
||||
switch c.SubState {
|
||||
default:
|
||||
}
|
||||
|
||||
println("test2222 yield:", 2)
|
||||
c.State++
|
||||
c.SubState = -1
|
||||
c.Out = 2
|
||||
return
|
||||
case 2:
|
||||
switch c.SubState {
|
||||
default:
|
||||
}
|
||||
c.State = -1
|
||||
c.SubState = -1
|
||||
default:
|
||||
c.State = -1
|
||||
c.SubState = -1
|
||||
return
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user