Documentation
¶
Overview ¶
Package keepawake holds a macOS power assertion while ogcode is doing work that should not be cut short by the display or the system going to sleep — specifically, for the duration of an agent turn.
It is reference counted: concurrent turns (the server and a worker, or a nested deep_search loop running alongside its parent) share a single OS assertion that is released only once the last turn finishes. The assertion used is PreventUserIdleDisplaySleep, which keeps the screen on and, because the system cannot idle-sleep while the display is up, also prevents idle system sleep — matching "keep the Mac and its screen awake while a turn runs".
On non-macOS platforms, and whenever OGCODE_NO_KEEP_AWAKE is set, every call is a no-op.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Acquire ¶
func Acquire(reason string) (release func())
Acquire signals that work is in progress that should keep the Mac awake. It returns a release function that is safe to call any number of times from any goroutine; only the first call counts, so `defer release()` is correct even on panic-recovery paths that might run it twice.
While at least one Acquire is outstanding a single power assertion is held, released when the last outstanding release runs. Best effort: if the OS refuses the assertion the turn proceeds anyway, just without sleep protection.
Types ¶
This section is empty.