Documentation
¶
Index ¶
- type EventLoop
- func (loop *EventLoop) ClearInterval(i *Interval)
- func (loop *EventLoop) ClearTimeout(t *Timer)
- func (loop *EventLoop) Run(fn func(*goscript.Runtime))
- func (loop *EventLoop) RunOnLoop(fn func(*goscript.Runtime))
- func (loop *EventLoop) SetInterval(fn func(*goscript.Runtime), timeout time.Duration) *Interval
- func (loop *EventLoop) SetTimeout(fn func(*goscript.Runtime), timeout time.Duration) *Timer
- func (loop *EventLoop) Start()
- func (loop *EventLoop) Stop()
- type Interval
- type Option
- type Timer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventLoop ¶
type EventLoop struct {
// contains filtered or unexported fields
}
func NewEventLoop ¶
func (*EventLoop) ClearInterval ¶
ClearInterval 取消了 SetInterval 返回的 Interval ClearInterval 在事件循环内部或外部调用都是安全的
func (*EventLoop) ClearTimeout ¶
ClearTimeout 取消由 SetTimeout 返回的,还没有运行的定时器 ClearTimeout 在事件循环内部或外部调用都是安全的
func (*EventLoop) Run ¶
Run 调用指定的函数,启动事件循环并等待,直到没有更多的延迟任务需要运行,之后停止循环并返回 传递给该函数的 Runtime 实例以及由其派生的任何值都不能在该函数之外使用 当事件循环已经运行时,不要使用这个函数,请使用 RunOnLoop() 代替 如果事件循环已经开始,调用它将产生 panic
func (*EventLoop) RunOnLoop ¶
RunOnLoop 将在循环的上下文中尽快运行指定的函数 运行的顺序被保留(即函数将按照调用 RunOnLoop() 的相同顺序被调用) 传递给函数的 Runtime 实例以及从它派生出来的任何值都不能在函数之外使用,在循环内部或外部调用都是安全的
func (*EventLoop) SetInterval ¶
SetInterval 在每个指定的超时时间段后,在事件循环的上下文中重复运行指定的函数 SetInterval 返回一个 Interval,可以传递给 ClearInterval 传递给该函数的 Runtime 实例以及由它派生的任何值都不能在该函数之外使用 SetInterval 在事件循环内部或外部调用都是安全的
func (*EventLoop) SetTimeout ¶
SetTimeout 在指定的超时周期触发后,在事件循环的上下文中运行指定的函数 SetTimeout 返回一个 Timer,可以传递给 ClearTimeoutSetTimeout 传递给函数的 Runtime 实例和任何由它派生的值都不能在函数之外使用 SetTimeout 在事件循环内部或外部调用都是安全的
type Option ¶
type Option func(*EventLoop)
func EnableConsole ¶
EnableConsole 控制 console 模块是否被加载到事件循环所使用的 Runtime 中 默认情况下,事件循环在创建时加载了 console 模块,将 EnableConsole(false) 传递给 NewEventLoop 可以禁止这种行为