Skip to main content

Module background

Module background 

Source
Expand description

Background execution: ask the OS to keep running briefly after the app is backgrounded, so in-flight work (e.g. draining a recognition queue) can finish instead of being suspended immediately.

The platform backend installs an implementation via set_platform_background_activity (iOS beginBackgroundTask, Android a foreground service). No default: background_activity returns None where unsupported, and the app simply runs only while foregrounded.

Structs§

BackgroundWorkLease
A claim that important work needs the host’s background execution allowance. The allowance remains active until every outstanding lease is dropped.

Traits§

BackgroundActivity
Marks periods of important work so the platform grants background running time. Implementations are Send + Sync (the app toggles activity from its worker threads).

Functions§

acquire_background_work
Acquires background execution for one independent operation.
background_active
Whether at least one background-work lease is active.
background_activity
The registered background-activity handler, or None where unsupported.
clear_platform_background_activity
Removes any registered handler (tests/teardown).
set_platform_background_activity
Installs the platform background-activity handler, replacing any previous one.

Type Aliases§

BackgroundActivityRef