diff options
author | 2023-04-07 06:20:40 +1000 | |
---|---|---|
committer | 2023-04-07 06:20:40 +1000 | |
commit | b67b969bf0911d71396c77e42d85ddfe80de6f20 (patch) | |
tree | 8d964eac6e0c4c849dc2b9b0b3742154c6c943d4 /plugins/timer/init.lua | |
parent | c4282fecede9032be78028e8fde737d44bf2b7c6 (diff) |
-Improved some Lua APIs:
* Moved several machine lifecycle callbacks to the notifier/subscriber
model. The old callback registration model is still available for
them for now, but prints a deprecation warning.
* Added pre-save/post-load notifications.
* Use a single allocated timer rather than one anonymous timer per
waiter. Waiters no longer prevent saved states from being loaded.
* Clean up outstanding waiters on stop or state load rather than just
leaking them.
* Started documenting parts of the emulator interface object that should
be relatively stable.
-imagedev/avivideo.cpp: Fixed an object leak on unload. Also changed
some other media image devices to use smart pointers.
Diffstat (limited to 'plugins/timer/init.lua')
-rw-r--r-- | plugins/timer/init.lua | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/plugins/timer/init.lua b/plugins/timer/init.lua index 35dbb6431ac..1d67472b3c2 100644 --- a/plugins/timer/init.lua +++ b/plugins/timer/init.lua @@ -1,5 +1,6 @@ -- license:BSD-3-Clause -- copyright-holders:Vas Crabb +-- TODO: track time properly across soft reset and state load local exports = { name = 'timer', version = '0.0.3', @@ -9,6 +10,8 @@ local exports = { local timer = exports +local reset_subscription, stop_subscription + function timer.startplugin() local total_time = 0 local start_time = 0 @@ -53,8 +56,8 @@ function timer.startplugin() end - emu.register_start( - function() + reset_subscription = emu.add_machine_reset_notifier( + function () if emu.romname() ~= '___empty' then start_time = os.time() local persister = require('timer/timer_persist') @@ -62,8 +65,8 @@ function timer.startplugin() end end) - emu.register_stop( - function() + stop_subscription = emu.add_machine_stop_notifier( + function () if emu.romname() ~= '___empty' then local persister = require('timer/timer_persist') persister:update_totals(start_time) |