Documentation ¶
Index ¶
- Variables
- func Async(provider gctx.ConcurrentContextProvider, ...) async.AsyncRet
- func AsyncVoid(provider gctx.ConcurrentContextProvider, ...) async.AsyncRet
- func Go(ctx context.Context, fun generic.FuncVar1[context.Context, any, async.Ret], ...) async.AsyncRet
- func GoVoid(ctx context.Context, fun generic.ActionVar1[context.Context, any], va ...any) async.AsyncRet
- func ReadChan[T any](ctx context.Context, ch <-chan T) async.AsyncRet
- func TimeAfter(ctx context.Context, dur time.Duration) async.AsyncRet
- func TimeAt(ctx context.Context, at time.Time) async.AsyncRet
- func TimeTick(ctx context.Context, dur time.Duration) async.AsyncRet
- func UnsafeRuntime(runtime Runtime) _UnsafeRuntime
- type AwaitDirector
- func (ad AwaitDirector) All(fun generic.ActionVar2[runtime.Context, []async.Ret, any], va ...any)
- func (ad AwaitDirector) Any(fun generic.ActionVar2[runtime.Context, async.Ret, any], va ...any)
- func (ad AwaitDirector) AnyOK(fun generic.ActionVar2[runtime.Context, async.Ret, any], va ...any)
- func (ad AwaitDirector) Pipe(ctx context.Context, fun generic.ActionVar2[runtime.Context, async.Ret, any], ...)
- type CustomGC
- type LifecycleComponentAwake
- type LifecycleComponentDispose
- type LifecycleComponentLateUpdate
- type LifecycleComponentShut
- type LifecycleComponentStart
- type LifecycleComponentUpdate
- type LifecycleEntityAwake
- type LifecycleEntityDispose
- type LifecycleEntityLateUpdate
- type LifecycleEntityShut
- type LifecycleEntityStart
- type LifecycleEntityUpdate
- type LifecyclePluginInit
- type LifecyclePluginShut
- type Running
- type Runtime
- type RuntimeBehavior
- func (rt *RuntimeBehavior) GetCompositeFaceCache() iface.Cache
- func (rt *RuntimeBehavior) GetConcurrentContext() iface.Cache
- func (rt *RuntimeBehavior) GetCurrentContext() iface.Cache
- func (rt *RuntimeBehavior) OnComponentDestroySelf(comp ec.Component)
- func (rt *RuntimeBehavior) OnEntityDestroySelf(entity ec.Entity)
- func (rt *RuntimeBehavior) OnEntityMgrAddEntity(entityMgr runtime.EntityMgr, entity ec.Entity)
- func (rt *RuntimeBehavior) OnEntityMgrEntityAddComponents(entityMgr runtime.EntityMgr, entity ec.Entity, components []ec.Component)
- func (rt *RuntimeBehavior) OnEntityMgrEntityFirstAccessComponent(entityMgr runtime.EntityMgr, entity ec.Entity, component ec.Component)
- func (rt *RuntimeBehavior) OnEntityMgrEntityRemoveComponent(entityMgr runtime.EntityMgr, entity ec.Entity, component ec.Component)
- func (rt *RuntimeBehavior) OnEntityMgrRemoveEntity(entityMgr runtime.EntityMgr, entity ec.Entity)
- func (rt *RuntimeBehavior) Play(delta time.Duration) (err error)
- func (rt *RuntimeBehavior) PlayAt(at time.Duration) (err error)
- func (rt *RuntimeBehavior) PlayAtFrames(at int64) (err error)
- func (rt *RuntimeBehavior) PlayFrames(delta int64) (err error)
- func (rt *RuntimeBehavior) PushCall(fun generic.FuncVar0[any, async.Ret], va ...any) async.AsyncRet
- func (rt *RuntimeBehavior) PushCallDelegate(fun generic.DelegateFuncVar0[any, async.Ret], va ...any) async.AsyncRet
- func (rt *RuntimeBehavior) PushCallVoid(fun generic.ActionVar0[any], va ...any) async.AsyncRet
- func (rt *RuntimeBehavior) PushCallVoidDelegate(fun generic.DelegateActionVar0[any], va ...any) async.AsyncRet
- func (rt *RuntimeBehavior) Run() <-chan struct{}
- func (rt *RuntimeBehavior) Terminate() <-chan struct{}
- func (rt *RuntimeBehavior) TerminatedChan() <-chan struct{}
- type RuntimeOptions
Constants ¶
This section is empty.
Variables ¶
var ( ErrTiny = exception.ErrTiny // 内核错误 ErrPanicked = exception.ErrPanicked // panic错误 ErrArgs = exception.ErrArgs // 参数错误 ErrRuntime = fmt.Errorf("%w: runtime", ErrTiny) // 运行时错误 ErrService = fmt.Errorf("%w: service", ErrTiny) // 服务错误 )
var ( ErrProcessQueueClosed = fmt.Errorf("%w: process queue is closed", ErrRuntime) // 任务处理流水线关闭 ErrProcessQueueFull = fmt.Errorf("%w: process queue is full", ErrRuntime) // 任务处理流水线已满 )
var (
ErrAllFailures = fmt.Errorf("%w: all of async result failures", exception.ErrTiny)
)
var (
ErrCtrlChanClosed = fmt.Errorf("%w: ctrl chan is closed", ErrRuntime) // 运行控制已关闭
)
var With _RuntimeOption
Functions ¶
func Async ¶
func Async(provider gctx.ConcurrentContextProvider, fun generic.FuncVar1[runtime.Context, any, async.Ret], va ...any) async.AsyncRet
Async 异步执行代码,有返回值
func AsyncVoid ¶
func AsyncVoid(provider gctx.ConcurrentContextProvider, fun generic.ActionVar1[runtime.Context, any], va ...any) async.AsyncRet
AsyncVoid 异步执行代码,无返回值
func Go ¶
func Go(ctx context.Context, fun generic.FuncVar1[context.Context, any, async.Ret], va ...any) async.AsyncRet
Go 使用新线程执行代码,有返回值
func GoVoid ¶
func GoVoid(ctx context.Context, fun generic.ActionVar1[context.Context, any], va ...any) async.AsyncRet
GoVoid 使用新线程执行代码,无返回值
func UnsafeRuntime ¶
func UnsafeRuntime(runtime Runtime) _UnsafeRuntime
Types ¶
type AwaitDirector ¶
type AwaitDirector struct {
// contains filtered or unexported fields
}
AwaitDirector 异步等待分发器
func Await ¶
func Await(provider gctx.CurrentContextProvider, asyncRet ...async.AsyncRet) AwaitDirector
Await 异步等待结果返回
func (AwaitDirector) All ¶
func (ad AwaitDirector) All(fun generic.ActionVar2[runtime.Context, []async.Ret, any], va ...any)
All 异步等待所有结果返回
func (AwaitDirector) Any ¶
func (ad AwaitDirector) Any(fun generic.ActionVar2[runtime.Context, async.Ret, any], va ...any)
Any 异步等待任意一个结果返回
type CustomGC ¶
type CustomGC = generic.DelegateAction1[Runtime] // 自定义GC函数
type LifecycleComponentAwake ¶
type LifecycleComponentAwake interface {
Awake()
}
LifecycleComponentAwake 组件的生命周期进入唤醒(awake)时的回调,组件实现此接口即可使用
type LifecycleComponentDispose ¶
type LifecycleComponentDispose interface {
Dispose()
}
LifecycleComponentDispose 组件的生命周期进入死亡(death)时的回调,组件实现此接口即可使用
type LifecycleComponentLateUpdate ¶
type LifecycleComponentLateUpdate = eventLateUpdate
LifecycleComponentLateUpdate 如果开启运行时的帧更新特性,那么组件状态为活跃(alive)时,将会收到这个帧迟滞更新(late update)回调,组件实现此接口即可使用
type LifecycleComponentShut ¶
type LifecycleComponentShut interface {
Shut()
}
LifecycleComponentShut 组件的生命周期进入结束(shut)时的回调,组件实现此接口即可使用
type LifecycleComponentStart ¶
type LifecycleComponentStart interface {
Start()
}
LifecycleComponentStart 组件的生命周期进入开始(start)时的回调,组件实现此接口即可使用
type LifecycleComponentUpdate ¶
type LifecycleComponentUpdate = eventUpdate
LifecycleComponentUpdate 如果开启运行时的帧更新特性,那么组件状态为活跃(alive)时,将会收到这个帧更新(update)回调,组件实现此接口即可使用
type LifecycleEntityAwake ¶
type LifecycleEntityAwake interface {
Awake()
}
LifecycleEntityAwake 实体的生命周期进入唤醒(awake)时的回调,实体实现此接口即可使用
type LifecycleEntityDispose ¶
type LifecycleEntityDispose interface {
Dispose()
}
LifecycleEntityDispose 实体的生命周期进入死亡(death)时的回调,实体实现此接口即可使用
type LifecycleEntityLateUpdate ¶
type LifecycleEntityLateUpdate = eventLateUpdate
LifecycleEntityLateUpdate 如果开启运行时的帧更新特性,那么实体状态为活跃(alive)时,将会收到这个帧迟滞更新(late update)回调,实体实现此接口即可使用
type LifecycleEntityShut ¶
type LifecycleEntityShut interface {
Shut()
}
LifecycleEntityShut 实体的生命周期进入结束(shut)时的回调,实体实现此接口即可使用
type LifecycleEntityStart ¶
type LifecycleEntityStart interface {
Start()
}
LifecycleEntityStart 实体的生命周期进入开始(start)时的回调,实体实现此接口即可使用
type LifecycleEntityUpdate ¶
type LifecycleEntityUpdate = eventUpdate
LifecycleEntityUpdate 如果开启运行时的帧更新特性,那么实体状态为活跃(alive)时,将会收到这个帧更新(update)回调,实体实现此接口即可使用
type LifecyclePluginInit ¶
LifecyclePluginInit 运行时上的插件初始化回调,插件实现此接口即可使用
type LifecyclePluginShut ¶
LifecyclePluginShut 运行时上的插件结束回调,插件实现此接口即可使用
type Running ¶
type Running interface { // Run 运行 Run() <-chan struct{} // Play 播放指定时长 Play(delta time.Duration) error // PlayAt 播放至指定位置 PlayAt(at time.Duration) error // PlayFrames 播放指定帧数 PlayFrames(delta int64) error // PlayAtFrames 播放至指定帧数 PlayAtFrames(at int64) error // Terminate 停止 Terminate() <-chan struct{} // TerminatedChan 已停止chan TerminatedChan() <-chan struct{} }
Running 运行接口
type Runtime ¶
type Runtime interface { gctx.CurrentContextProvider gctx.ConcurrentContextProvider async.Callee reinterpret.CompositeProvider Running // contains filtered or unexported methods }
Runtime 运行时接口
func NewRuntime ¶
NewRuntime 创建运行时
func UnsafeNewRuntime
deprecated
func UnsafeNewRuntime(ctx runtime.Context, options RuntimeOptions) Runtime
Deprecated: UnsafeNewRuntime 内部创建运行时
type RuntimeBehavior ¶
type RuntimeBehavior struct {
// contains filtered or unexported fields
}
RuntimeBehavior 运行时行为,在需要扩展运行时能力时,匿名嵌入至运行时结构体中
func (*RuntimeBehavior) GetCompositeFaceCache ¶
func (rt *RuntimeBehavior) GetCompositeFaceCache() iface.Cache
GetCompositeFaceCache 支持重新解释类型
func (*RuntimeBehavior) GetConcurrentContext ¶
func (rt *RuntimeBehavior) GetConcurrentContext() iface.Cache
GetConcurrentContext 获取多线程安全的上下文
func (*RuntimeBehavior) GetCurrentContext ¶
func (rt *RuntimeBehavior) GetCurrentContext() iface.Cache
GetCurrentContext 获取当前上下文
func (*RuntimeBehavior) OnComponentDestroySelf ¶
func (rt *RuntimeBehavior) OnComponentDestroySelf(comp ec.Component)
OnComponentDestroySelf 事件处理器:组件销毁自身
func (*RuntimeBehavior) OnEntityDestroySelf ¶
func (rt *RuntimeBehavior) OnEntityDestroySelf(entity ec.Entity)
OnEntityDestroySelf 事件处理器:实体销毁自身
func (*RuntimeBehavior) OnEntityMgrAddEntity ¶
func (rt *RuntimeBehavior) OnEntityMgrAddEntity(entityMgr runtime.EntityMgr, entity ec.Entity)
OnEntityMgrAddEntity 事件处理器:实体管理器添加实体
func (*RuntimeBehavior) OnEntityMgrEntityAddComponents ¶
func (rt *RuntimeBehavior) OnEntityMgrEntityAddComponents(entityMgr runtime.EntityMgr, entity ec.Entity, components []ec.Component)
OnEntityMgrEntityAddComponents 事件处理器:实体管理器中的实体添加组件
func (*RuntimeBehavior) OnEntityMgrEntityFirstAccessComponent ¶
func (rt *RuntimeBehavior) OnEntityMgrEntityFirstAccessComponent(entityMgr runtime.EntityMgr, entity ec.Entity, component ec.Component)
OnEntityMgrEntityFirstAccessComponent 事件处理器:实体管理器中的实体首次访问组件
func (*RuntimeBehavior) OnEntityMgrEntityRemoveComponent ¶
func (rt *RuntimeBehavior) OnEntityMgrEntityRemoveComponent(entityMgr runtime.EntityMgr, entity ec.Entity, component ec.Component)
OnEntityMgrEntityRemoveComponent 事件处理器:实体管理器中的实体删除组件
func (*RuntimeBehavior) OnEntityMgrRemoveEntity ¶
func (rt *RuntimeBehavior) OnEntityMgrRemoveEntity(entityMgr runtime.EntityMgr, entity ec.Entity)
OnEntityMgrRemoveEntity 事件处理器:实体管理器删除实体
func (*RuntimeBehavior) Play ¶
func (rt *RuntimeBehavior) Play(delta time.Duration) (err error)
Play 播放指定时长
func (*RuntimeBehavior) PlayAt ¶
func (rt *RuntimeBehavior) PlayAt(at time.Duration) (err error)
PlayAt 播放至指定位置
func (*RuntimeBehavior) PlayAtFrames ¶
func (rt *RuntimeBehavior) PlayAtFrames(at int64) (err error)
PlayAtFrames 播放至指定帧数
func (*RuntimeBehavior) PlayFrames ¶
func (rt *RuntimeBehavior) PlayFrames(delta int64) (err error)
PlayFrames 播放指定帧数
func (*RuntimeBehavior) PushCallDelegate ¶
func (rt *RuntimeBehavior) PushCallDelegate(fun generic.DelegateFuncVar0[any, async.Ret], va ...any) async.AsyncRet
PushCallDelegate 将调用委托压入接受者的任务处理流水线,返回AsyncRet。
func (*RuntimeBehavior) PushCallVoid ¶
func (rt *RuntimeBehavior) PushCallVoid(fun generic.ActionVar0[any], va ...any) async.AsyncRet
PushCallVoid 将调用函数压入接受者的任务处理流水线,返回AsyncRet。
func (*RuntimeBehavior) PushCallVoidDelegate ¶
func (rt *RuntimeBehavior) PushCallVoidDelegate(fun generic.DelegateActionVar0[any], va ...any) async.AsyncRet
PushCallVoidDelegate 将调用委托压入接受者的任务处理流水线,返回AsyncRet。
func (*RuntimeBehavior) Terminate ¶
func (rt *RuntimeBehavior) Terminate() <-chan struct{}
Terminate 停止
func (*RuntimeBehavior) TerminatedChan ¶
func (rt *RuntimeBehavior) TerminatedChan() <-chan struct{}
TerminatedChan 已停止chan
type RuntimeOptions ¶
type RuntimeOptions struct { CompositeFace iface.Face[Runtime] // 扩展者,在扩展运行时自身能力时使用 AutoRun bool // 是否开启自动运行 ProcessQueueCapacity int // 任务处理流水线大小 Frame runtime.Frame // 帧,设置为nil表示不使用帧更新特性 GCInterval time.Duration // GC间隔时长 CustomGC CustomGC // 自定义GC }
RuntimeOptions 创建运行时的所有选项
Source Files ¶
- async.go
- await.go
- errors.go
- lifecycle_component.go
- lifecycle_entity.go
- lifecycle_plugin.go
- running.go
- runtime.go
- runtime_callee.go
- runtime_event.go
- runtime_event_code.go
- runtime_gc.go
- runtime_looping_manual.go
- runtime_looping_noframe.go
- runtime_looping_realtime.go
- runtime_looping_simulate.go
- runtime_options.go
- runtime_running.go
- runtime_task.go
- unsafe_runtime.go