Documentation Index
Fetch the complete documentation index at: https://mintlify.com/LiveSplit/livesplit-core/llms.txt
Use this file to discover all available pages before exploring further.
SharedTimer is a type alias for Arc<RwLock<Timer>>, available when the std feature is enabled. It allows multiple owners across threads to safely read and mutate the timer without data races. The HotkeySystem and AutoSplittingRuntime both require a SharedTimer to send commands to the timer from background threads.
Creating a SharedTimer
Convert an ownedTimer into a SharedTimer using Timer::into_shared():
SharedTimer implements Clone — cloning it creates a new Arc reference to the same underlying RwLock<Timer>, not a deep copy of the timer.
Reading and Writing
Useread() and write() to access the underlying Timer:
Hold read and write locks only for the duration of your operation. Holding a write lock while performing slow I/O or waiting on user input will block all other threads that need the timer.
Sharing Across Threads
Using with HotkeySystem and AutoSplittingRuntime
BothHotkeySystem and AutoSplittingRuntime accept a SharedTimer (or any type implementing the CommandSink trait, which SharedTimer implements via the std feature):
CommandSink Trait
SharedTimer implements the CommandSink trait, which defines async methods for all timer commands. This is the interface used by the hotkey system and auto splitter to control the timer indirectly:
| Method | Equivalent Timer method |
|---|---|
start() | timer.start() |
split() | timer.split() |
split_or_start() | timer.split_or_start() |
reset(save_attempt) | timer.reset(update_splits) |
undo_split() | timer.undo_split() |
skip_split() | timer.skip_split() |
pause() / resume() | timer.pause() / timer.resume() |
toggle_pause_or_start() | timer.toggle_pause_or_start() |
set_game_time(time) | timer.set_game_time(time) |
set_loading_times(time) | timer.set_loading_times(time) |
set_custom_variable(name, value) | timer.set_custom_variable(name, value) |