1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//! Keeping a channel's typing indicator alive while work is detached (#812).
//!
//! Every channel expires its indicator after a few seconds, so it has to be
//! re-sent on a tick, and every channel needs the same unusual tail: spawning
//! a detached command ENDS the turn, so the turn's own loop stops at exactly
//! the moment the user most needs to see that something is happening.
//!
//! Telegram and Discord had that tail written out twice, with the same
//! before-sleeping ordering and the same rationale in both comments. Only the
//! ping differs, so only the ping is a parameter.
use Arc;
use Duration;
use Uuid;
use crateBackgroundTaskManager;
/// Ping `send` every `tick` for as long as `session_id` has detached work.
///
/// Returns immediately when no manager is wired, which is what a surface
/// without background support needs. The first ping goes out BEFORE the first
/// sleep: the turn has just ended and its own last ping is already expiring,
/// so waiting a full tick would leave a visible dead gap at the handover.
pub async