Documentation ¶
Index ¶
- type EventLoop
- func (loop *EventLoop) ClearInterval(i *Interval)
- func (loop *EventLoop) ClearTimeout(t *Timer)
- func (loop *EventLoop) Registry() *require.Registry
- func (loop *EventLoop) Run(fn func(*goja.Runtime))
- func (loop *EventLoop) RunOnLoop(fn func(*goja.Runtime))
- func (loop *EventLoop) Runtime() *goja.Runtime
- func (loop *EventLoop) SetInterval(fn func(*goja.Runtime), timeout time.Duration) *Interval
- func (loop *EventLoop) SetTimeout(fn func(*goja.Runtime), timeout time.Duration) *Timer
- func (loop *EventLoop) Start() *goja.Runtime
- func (loop *EventLoop) Stop() int
- func (loop *EventLoop) StopNoWait()
- func (loop *EventLoop) Wait()
- type Immediate
- 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 cancels an Interval returned by SetInterval. ClearInterval is safe to call inside or outside the loop.
func (*EventLoop) ClearTimeout ¶
ClearTimeout cancels a Timer returned by SetTimeout if it has not run yet. ClearTimeout is safe to call inside or outside the loop.
func (*EventLoop) Run ¶
Run calls the specified function, starts the event loop and waits until there are no more delayed jobs to run after which it stops the loop and returns. The instance of goja.Runtime that is passed to the function and any Values derived from it must not be used outside the function. Do NOT use this function while the loop is already running. Use RunOnLoop() instead. If the loop is already started it will panic.
func (*EventLoop) RunOnLoop ¶
RunOnLoop schedules to run the specified function in the context of the loop as soon as possible. The order of the runs is preserved (i.e. the functions will be called in the same order as calls to RunOnLoop()) The instance of goja.Runtime that is passed to the function and any Values derived from it must not be used outside the function. It is safe to call inside or outside the loop.
func (*EventLoop) SetInterval ¶
SetInterval schedules to repeatedly run the specified function in the context of the loop as soon as possible after every specified timeout period. SetInterval returns an Interval which can be passed to ClearInterval. The instance of goja.Runtime that is passed to the function and any Values derived from it must not be used outside the function. SetInterval is safe to call inside or outside the loop.
func (*EventLoop) SetTimeout ¶
SetTimeout schedules to run the specified function in the context of the loop as soon as possible after the specified timeout period. SetTimeout returns a Timer which can be passed to ClearTimeout. The instance of goja.Runtime that is passed to the function and any Values derived from it must not be used outside the function. SetTimeout is safe to call inside or outside the loop.
func (*EventLoop) Start ¶
Start the event loop in the background. The loop continues to run until Stop() is called. If the loop is already started it will panic.
func (*EventLoop) Stop ¶
Stop the loop that was started with Start(). After this function returns there will be no more jobs executed by the loop. It is possible to call Start() or Run() again after this to resume the execution. Note, it does not cancel active timeouts. It is not allowed to run Start() (or Run()) and Stop() concurrently. Calling Stop() on a non-running loop has no effect. It is not allowed to call Stop() from the loop, because it is synchronous and cannot complete until the loop is not running any jobs. Use StopNoWait() instead. return number of jobs remaining
func (*EventLoop) StopNoWait ¶
func (loop *EventLoop) StopNoWait()
StopNoWait tells the loop to stop and returns immediately. Can be used inside the loop. Calling it on a non-running loop has no effect.