Documentation
¶
Overview ¶
Package scheduler provides page-scoped timing APIs exposed to WebGo programs.
Index ¶
- Constants
- type API
- func (api *API) CancelAnimationFrame(id FrameID) bool
- func (api *API) ClearTimer(id TimerID) bool
- func (api *API) Close()
- func (api *API) HasAnimationFrameCallbacks() bool
- func (api *API) RequestAnimationFrame(callback func(Timestamp)) (FrameID, error)
- func (api *API) RunAnimationFrame(current time.Time) bool
- func (api *API) RunDue(current time.Time)
- func (api *API) SetBackground(background bool)
- func (api *API) SetFrameScope(scope func(time.Time, func()))
- func (api *API) SetInterval(interval time.Duration, callback func()) (TimerID, error)
- func (api *API) SetTimeout(delay time.Duration, callback func()) (TimerID, error)
- type Clock
- type FrameID
- type TimerID
- type Timestamp
Constants ¶
const ( Millisecond = time.Millisecond Second = time.Second // MaxTimerDuration bounds retained callbacks and deadline arithmetic. MaxTimerDuration = 365 * 24 * time.Hour // MaxTimersPerPage bounds callbacks retained by timeouts and intervals. MaxTimersPerPage = 10000 // MaxFrameCallbacksPerPage bounds callbacks retained until the next frame. MaxFrameCallbacksPerPage = 10000 // MaxCallbacksPerTurn prevents one deadline from starving the Page queue. MaxCallbacksPerTurn = 1000 // MaxBackgroundCallbacksPerTurn limits work queued by a hidden tab. MaxBackgroundCallbacksPerTurn = 100 // MinBackgroundTimerDelay clamps hidden-tab timers. MinBackgroundTimerDelay = time.Second )
WebGo programs can build time.Duration values without importing the Go standard library, which is intentionally not part of the page API surface.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API owns the active timers for one page.
func NewPage ¶
NewPage creates a scheduler that waits for deadlines and delivers callbacks through enqueue.
func NewPageWithClock ¶
func NewPageWithClock(parent context.Context, clock Clock, enqueue func(func()) bool, requestFrame func()) *API
NewPageWithClock creates a manually driven page Scheduler. Embedders and tests advance timers through RunDue, so no wall-clock goroutine is started.
func (*API) CancelAnimationFrame ¶
CancelAnimationFrame removes a callback that has not started.
func (*API) ClearTimer ¶
ClearTimer cancels a timeout or interval before its next callback starts.
func (*API) Close ¶
func (api *API) Close()
Close cancels every timer and releases page callback references.
func (*API) HasAnimationFrameCallbacks ¶
HasAnimationFrameCallbacks reports whether another rendered frame is needed.
func (*API) RequestAnimationFrame ¶
RequestAnimationFrame registers callback for the next rendered frame.
func (*API) RunAnimationFrame ¶
RunAnimationFrame delivers the callbacks captured for one frame. Callers must invoke it from the page event queue.
func (*API) RunDue ¶
RunDue synchronously queues all timers whose deadline is at or before current. It is intended for a manually driven Scheduler.
func (*API) SetBackground ¶ added in v0.10.0
SetBackground applies hidden-tab timer clamping and callback budgeting.
func (*API) SetFrameScope ¶
SetFrameScope configures the page-owned scope used while frame callbacks run.
func (*API) SetInterval ¶
SetInterval registers callback to run repeatedly after each interval.