mirror of
https://github.com/bloeys/cogo.git
synced 2025-12-29 08:58:19 +00:00
95 lines
1.2 KiB
Go
Executable File
95 lines
1.2 KiB
Go
Executable File
// 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
|
|
}
|
|
}
|