Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if watchdogs are closed before operating on them #12

Merged
merged 3 commits into from
Jan 14, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/watchdog.toit
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class Watchdog extends ServiceResourceProxy:
reacted upon.
*/
start --s/int -> none:
if is-closed: throw "ALREADY_CLOSED"
is-stopped_ = false
client := (client_ as WatchdogServiceClient)
client.start_ handle_ s
Expand All @@ -133,6 +134,7 @@ class Watchdog extends ServiceResourceProxy:
Does nothing if the watchdog is not started.
*/
feed -> none:
if is-closed: throw "ALREADY_CLOSED"
client := (client_ as WatchdogServiceClient)
client.feed_ handle_

Expand All @@ -142,6 +144,7 @@ class Watchdog extends ServiceResourceProxy:
Does nothing if the watchdog is not started.
*/
stop -> none:
if is-closed: throw "ALREADY_CLOSED"
is-stopped_ = true
client := (client_ as WatchdogServiceClient)
client.stop_ handle_
Expand All @@ -152,4 +155,8 @@ class Watchdog extends ServiceResourceProxy:
close -> none:
super
if not is-stopped_:
throw "WATCHDOG_NOT_STOPPED"
// Produce a stack trace to draw attention to the
// fact that a closed, non-stopped watchdog will
// eventually lead to problems, because it cannot
// be fed anymore.
catch --trace: throw "WATCHDOG_NOT_STOPPED"
Loading