37 lines
589 B
Go
37 lines
589 B
Go
package main
|
||
|
||
import (
|
||
"fmt"
|
||
"time"
|
||
|
||
"joylink.club/ecs"
|
||
)
|
||
|
||
func main() {
|
||
sim := ecs.NewWorld(20)
|
||
sim.StartUp()
|
||
sim.Pause()
|
||
|
||
go func() {
|
||
time.Sleep(1 * time.Second)
|
||
sim.Resume()
|
||
}()
|
||
|
||
// 超出channel缓冲区(超出后,会阻塞)
|
||
for i := 0; i < 50; i++ {
|
||
sim.Execute(func() {
|
||
fmt.Println("测试执行")
|
||
})
|
||
}
|
||
|
||
// 请求功能测试
|
||
resultFuture := ecs.Request[int](sim, func() ecs.Result[int] {
|
||
fmt.Println("执行请求")
|
||
return ecs.NewOkResult[int](20)
|
||
})
|
||
result := <-resultFuture
|
||
fmt.Println("执行结果:", result)
|
||
|
||
time.Sleep(2 * time.Second)
|
||
}
|