播放游戏时,停止待机任务

This commit is contained in:
2025-02-26 19:45:47 +08:00
parent 8b080a8081
commit 593d7758bf
19 changed files with 422 additions and 275 deletions

View File

@@ -17,7 +17,8 @@ const EndKey endKeyType = "end"
type EndType int
const (
EndTimer EndType = iota + 1
End = iota
EndTimeout
EndStop
)
@@ -75,6 +76,17 @@ func (c *Context) Handler() HandlerFunc {
return c.handlers.Last()
}
// Hold 在当前中保留一个锚点,以便后续可以从此恢复后续处理程序。
func (c *Context) Hold() int8 {
return c.index
}
// Resume 从 Hold 保留的锚点恢复后续处理程序。
func (c *Context) Resume(index int8) {
c.index = index
c.Next()
}
/************************************/
/*********** FLOW CONTROL ***********/
/************************************/
@@ -106,6 +118,10 @@ func (c *Context) Abort() {
c.index = abortIndex
}
func (c *Context) Done() <-chan struct{} {
return c.Context.Done()
}
func WithValue[T any](ctx *Context, k any, v T) {
ctx.value = &KeyValue{
parent: ctx.value,