Documentation
¶
Overview ¶
Package loop has the plain-Go parts of the run loop that macOS and iOS share (SPEC §29.3, §30.2): the heap of timers that one CFRunLoopTimer is set to, the merging of the frame requests of a window, the pacer that starts and stops the display link, and the gate that offers one tick of a display link's thread at a time to the loop. Nothing here calls the operating system, so the tests run on every host.
Flutter: no counterpart
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FrameRequests ¶
type FrameRequests struct {
// contains filtered or unexported fields
}
FrameRequests merges the requests of one window for a frame (SPEC §29.3): any number made while a frame is wanted are one frame, a request made during a frame asks for the next, and the request of a window that cannot draw (minimized, hidden) is kept until it can.
Flutter: shell/platform/darwin/macos/framework/Source/FlutterVSyncWaiter.mm (one request is answered by one tick of the display link)
func (*FrameRequests) Clear ¶
func (f *FrameRequests) Clear()
Clear drops the request: a frame was drawn for another reason (a live resize draws at once).
Flutter: no counterpart
func (*FrameRequests) Request ¶
func (f *FrameRequests) Request()
Request records a request for a frame.
Flutter: no counterpart
func (*FrameRequests) Take ¶
func (f *FrameRequests) Take(canDraw bool) bool
Take says whether the window draws in this tick: a frame is wanted and the window can draw it. The Request is consumed before the frame is drawn, so that a request made during the frame asks for the one after it.
Flutter: no counterpart
func (*FrameRequests) Wanted ¶
func (f *FrameRequests) Wanted() bool
Wanted says whether a frame is wanted now.
Flutter: no counterpart
type LinkPacer ¶
type LinkPacer struct {
// contains filtered or unexported fields
}
LinkPacer decides when the display link runs (SPEC §29.3): it runs only while some window wants a frame and can draw it, so an idle app has no link ticking. It belongs to the UI thread.
Flutter: no counterpart (FlutterDisplayLink is paused by the vsync waiter when nothing waits)
func (*LinkPacer) Running ¶
Running says whether the link is running now: Update last said to start it and has not said to stop it.
Flutter: no counterpart
type LinkWatch ¶
type LinkWatch struct {
// contains filtered or unexported fields
}
LinkWatch decides which of two display links paces the frames (SPEC §29.3): the preferred one (the view's CADisplayLink, which follows the display and its refresh rate) and a fallback that always ticks (a CVDisplayLink). The preferred link stays silent for a window on a display that sleeps, which is also what a Mac shows when it is used through Screen Sharing with its own screen asleep: the window is looked at and must be drawn. So the preferred link is watched while it runs: when a watch interval passes with no tick of it the fallback takes over, a tick of the preferred link takes the pacing back, and while the preferred link is silent every start goes to the fallback at once. It belongs to the UI thread.
Flutter: no counterpart (FlutterDisplayLink is a CVDisplayLink on every version of macOS)
func (*LinkWatch) Check ¶
Check is called when a watch interval has passed. It says whether the fallback must be started: the links run, the preferred one paces and it did not tick in the interval. The next interval starts.
Flutter: no counterpart
func (*LinkWatch) Fallback ¶
Fallback says whether the fallback paces the frames: a tick of it is a frame only then.
Flutter: no counterpart
func (*LinkWatch) Start ¶
Start is told that the links are wanted. It says whether the fallback must be started as well (the preferred link was silent the last time it was watched); the preferred link is always started, so that its first tick is seen.
Flutter: no counterpart
func (*LinkWatch) Stop ¶
func (w *LinkWatch) Stop()
Stop is told that no link is wanted any more. The fallback, when it ran, is stopped by the caller; that the preferred link was silent is remembered for the next Start.
Flutter: no counterpart
type TickGate ¶
type TickGate struct {
// contains filtered or unexported fields
}
TickGate lets one tick of a display link thread (CVDisplayLink calls back on a thread of its own) be offered to the loop at a time: a tick that arrives while the previous one is still waiting is dropped, as Flutter's FlutterDisplayLink does, so a slow loop never collects a queue of ticks. It is safe to use from the link's thread and from the UI thread.
Flutter: shell/platform/darwin/macos/framework/Source/FlutterDisplayLink.mm (the tick is dropped while the main thread has not handled the last)
type Timers ¶
type Timers struct {
// contains filtered or unexported fields
}
Timers is the platform's own heap of timers (SPEC §29.3): one CFRunLoopTimer is set to the earliest deadline (SetNextFire) and the heap runs what is due when it fires. It belongs to the UI thread, so it needs no lock.
Flutter: shell/platform/darwin/macos/framework/Source/FlutterRunLoop.swift FlutterRunLoop (its scheduled blocks run in the main run loop)
func (*Timers) Add ¶
Add arms fn to run at the time and returns the id to cancel it with.
Flutter: no counterpart
func (*Timers) Cancel ¶
Cancel disarms a timer and reports whether it was still armed.
Flutter: no counterpart
func (*Timers) Deadline ¶
Deadline is when the earliest timer is due; ok is false when none is armed, which makes the loop wait for ever.
Flutter: no counterpart