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

Update Timer doc comments #685

Merged
merged 5 commits into from
Jan 28, 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
37 changes: 18 additions & 19 deletions src/Timer.mo
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
/// Timers for one-off or periodic tasks. Applicable as part of the default mechanism.
/// If `moc` is invoked with `-no-timer`, the importing will fail.
rvanasa marked this conversation as resolved.
Show resolved Hide resolved
///
/// Note: If `moc` is invoked with `-no-timer`, the importing will fail.
/// The resolution of the timers is similar to the block rate,
/// so durations should be chosen well above that. For frequent
/// canister wake-ups, consider using the [heartbeat](https://internetcomputer.org/docs/current/motoko/main/writing-motoko/heartbeats) mechanism.
rvanasa marked this conversation as resolved.
Show resolved Hide resolved
///
/// Note: The resolution of the timers is in the order of the block rate,
/// so durations should be chosen well above that. For frequent
/// canister wake-ups the heartbeat mechanism should be considered.
/// The functionality described below is enabled only when the actor does not override it by declaring an explicit `system func timer`.
///
/// Note: The functionality described below is enabled only when the actor does not override it by declaring an explicit `system func timer`.
/// Timers are _not_ persisted across upgrades. One possible strategy
/// to re-establish timers after an upgrade is to walk stable variables
rvanasa marked this conversation as resolved.
Show resolved Hide resolved
/// in the `post_upgrade` hook and distill necessary timer information
/// from there.
///
/// Note: Timers are _not_ persisted across upgrades. One possible strategy
/// to re-establish timers after an upgrade is to walk stable variables
/// in the `post_upgrade` hook and distill necessary timer information
/// from there.
/// Using timers for security (e.g. access control) is strongly discouraged.
/// Make sure to inform yourself about state-of-the art dApp security.
/// If you must use timers for security controls, be sure
/// to consider reentrancy issues as well as the vanishing of timers on upgrades
/// and reinstalls.
rvanasa marked this conversation as resolved.
Show resolved Hide resolved
///
/// Note: Basing security (e.g. access control) on timers is almost always
/// the wrong choice. Be sure to inform yourself about state-of-the art
/// dApp security. If you _must use_ timers for security controls, be sure
/// to consider reentrancy issues, and the vanishing of timers on upgrades
/// and reinstalls.
///
/// Note: For further usage information for timers on the IC please consult
/// https://internetcomputer.org/docs/current/developer-docs/backend/periodic-tasks#timers-library-limitations
/// For further usage information for timers on the IC please consult
rvanasa marked this conversation as resolved.
Show resolved Hide resolved
/// [the documentation](https://internetcomputer.org/docs/current/developer-docs/backend/periodic-tasks#timers-library-limitations).
import { setTimer = setTimerNano; cancelTimer = cancel } = "mo:⛔";
import { fromIntWrap } = "Nat64";

Expand Down Expand Up @@ -68,8 +67,8 @@ module {
/// and not recognised `id`s nothing happens.
///
/// ```motoko no-repl
/// func deleteAppt(appt : Appointment) {
/// cancelTimer (appt.reminder);
/// func deleteAppointment(appointment : Appointment) {
/// cancelTimer (appointment.reminder);
/// // ...
/// };
/// ```
Expand Down
Loading