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

doc: add notes to Timer.mo #683

Merged
merged 7 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
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
2 changes: 1 addition & 1 deletion src/Debug.mo
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module {
///
/// NOTE: When running on an ICP network, all output is written to the [canister log](https://internetcomputer.org/docs/current/developer-docs/smart-contracts/maintain/logs) with the exclusion of any output
/// produced during the execution of non-replicated queries and composite queries.
/// In other environments, like the interpreter and stand-alone wasm engines, the output is written to standard out.
/// In other environments, like the interpreter and stand-alone wasm engines, the output is written to standard out.
///
/// ```motoko include=import
/// Debug.print "Hello New World!";
Expand Down
1 change: 0 additions & 1 deletion src/ExperimentalInternetComputer.mo
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ module {
/// Returns the time (in nanoseconds from the epoch start) by when the update message should
/// reply to the best effort message so that it can be received by the requesting canister.
/// Queries and non-best-effort update messages return zero.
///
public func replyDeadline() : Nat = Prim.nat64ToNat(Prim.replyDeadline());

}
25 changes: 21 additions & 4 deletions src/Timer.mo
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
/// Timers for one-off or periodic tasks.
/// Timers for one-off or periodic tasks. Applicable as part of the default mechanism.
///
/// Note: If `moc` is invoked with `-no-timer`, the importing will fail.
///
/// 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 heatbeat mechanism should be considered.

/// canister wake-ups the heartbeat mechanism should be considered.
///
/// Note: The functionality described below is enabled only when the actor does not override it by declaring an explicit `system func timer`.
///
/// 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.
///
/// 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
q
import { setTimer = setTimerNano; cancelTimer = cancel } = "mo:⛔";
ggreif marked this conversation as resolved.
Show resolved Hide resolved
import { fromIntWrap } = "Nat64";

Expand Down Expand Up @@ -40,7 +57,7 @@ module {
/// executes the future `job()` and reinserts itself for another expiration.
///
/// Note: A duration of 0 will only expire once.
/// Note: Since `job` can be called more than once (under rare circumstances),
/// Note: Since `job` can be called more than once per expiration (under rare circumstances),
/// it should not possess side-effects.
///
/// ```motoko no-repl
Expand Down
Loading