Expand description
Timer, thread, and async task management. Timer and thread management for asynchronous operations.
This module provides:
TimerId/ThreadId: Unique identifiers for timers and background threadsInstant/Duration: Cross-platform time types (works on no_std with tick counters)ThreadReceiver: Channel for receiving messages from the main thread- Callback types for thread communication and system time queries
Structs§
- Check
Thread Finished Callback - Wrapper for thread completion check callback.
- GetSystem
Time Callback - Instant
Ptr - FFI-safe wrapper around
std::time::Instantwith custom clone/drop callbacks. - Instant
PtrClone Callback - Instant
PtrDestructor Callback - Library
Send Thread MsgCallback - Wrapper for thread message send callback.
- System
Tick - Tick-based timestamp for systems without a real-time clock.
- System
Tick Diff - Represents a difference in ticks for systems that don’t support timing
- System
Time Diff - Duration represented as seconds + nanoseconds (mirrors
std::time::Duration). - Thread
Id - ID for uniquely identifying a background thread
- Thread
IdVec - Thread
IdVec Slice - C-compatible slice type for
$struct_name. This is a non-owning view into a Vec’s data. - Thread
Receiver - Channel endpoint for receiving messages from the main thread in a background thread.
- Thread
Receiver Destructor Callback - Wrapper for thread receiver destructor callback.
- Thread
Receiver Inner - Inner receiver state containing the actual channel and callbacks.
- Thread
Recv Callback - Wrapper for thread message receive callback.
- TimerId
- ID for uniquely identifying a timer
- Timer
IdVec - Timer
IdVec Slice - C-compatible slice type for
$struct_name. This is a non-owning view into a Vec’s data.
Enums§
- Duration
- A span of time, either from the system clock or as tick difference.
- Instant
- A point in time, either from the system clock or a tick counter.
- Option
Duration - Option
Instant - Option
Thread Id - Option
Thread Send Msg - Option
Timer Id - Terminate
Timer - Should a timer terminate or not - used to remove active timers
- Thread
IdVec Destructor - Thread
Send Msg - Message that can be sent from the main thread to the Thread using the
ThreadId. - Timer
IdVec Destructor
Constants§
- CAPABILITY_
PUMP_ TIMER_ ID - Timer ID for the single-threaded capability pump (MWA-A1).
- CURSOR_
BLINK_ TIMER_ ID - Timer ID for cursor blinking in contenteditable elements (~530ms interval)
- DRAG_
AUTOSCROLL_ TIMER_ ID - Timer ID for auto-scroll during drag operations near edges
- LONG_
PRESS_ TIMER_ ID - Timer ID for the one-shot long-press wake-up (MWA-B12).
- SCROLL_
MOMENTUM_ TIMER_ ID - Timer ID for scroll momentum/inertia animation
- TOOLTIP_
DELAY_ TIMER_ ID - Timer ID for tooltip show delay.
- USER_
TIMER_ ID_ START - First available ID for user-defined timers
Statics§
- TEST_
CLOCK_ OFFSET_ MS - Injectable test-clock offset, in milliseconds, added to every
Instant::now().
Functions§
- advance_
test_ clock_ ms - Advance the injectable test clock by
ms(E2Etick_ms). - get_
system_ time_ libstd - Default implementation that gets the current system time.
- test_
clock_ offset_ ms - The current test-clock offset in ms (0 unless
tick_mswas used).
Type Aliases§
- Check
Thread Finished Callback Type - Callback to check if a thread has finished execution.
- GetSystem
Time Callback Type - Get the current system type, equivalent to
std::time::Instant::now(), except it also works on systems that don’t have a clock (such as embedded timers) - Instant
PtrClone Callback Type - Instant
PtrDestructor Callback Type - Library
Send Thread MsgCallback Type - Callback to send a message to a background thread.
- Thread
IdVec Destructor Type - Thread
Receiver Destructor Callback Type - Callback to destroy a
ThreadReceiver. - Thread
Recv Callback Type - Callback for a running thread to receive messages from the main thread.
- Timer
IdVec Destructor Type