forked from lavina/lavina
1
0
Fork 0

fix links

This commit is contained in:
Nikita Vilunov 2024-01-29 23:17:08 +01:00
parent 614be92be3
commit b29fb68e8f
2 changed files with 9 additions and 4 deletions

View File

@ -1,10 +1,12 @@
use crate::prelude::*; use crate::prelude::*;
/// A handle to a task that can be gracefully terminated.
pub struct Terminator { pub struct Terminator {
signal: Promise<()>, signal: Promise<()>,
completion: JoinHandle<Result<()>>, completion: JoinHandle<Result<()>>,
} }
impl Terminator { impl Terminator {
/// Send a signal to the task to terminate and await its completion.
pub async fn terminate(self) -> Result<()> { pub async fn terminate(self) -> Result<()> {
match self.signal.send(()) { match self.signal.send(()) {
Ok(()) => {} Ok(()) => {}
@ -14,7 +16,10 @@ impl Terminator {
Ok(()) Ok(())
} }
/// Used to spawn managed tasks with support for graceful shutdown /// Spawn a task with support for graceful shutdown.
///
/// The launched task must listen for the termination signal and stop gracefully on receiving it.
/// The signal is sent by calling the `terminate` method on the returned `Terminator` instance outside the task.
pub fn spawn<Fun, Fut>(launcher: Fun) -> Terminator pub fn spawn<Fun, Fut>(launcher: Fun) -> Terminator
where where
Fun: FnOnce(Deferred<()>) -> Fut, Fun: FnOnce(Deferred<()>) -> Fut,

View File

@ -2,9 +2,9 @@
Multiprotocol chat server based on open protocols. Multiprotocol chat server based on open protocols.
- [How to run Lavina locally](docs/running.md) - [How to run Lavina locally](./docs/running.md)
- [Architectural diagrams](docs/flow.md) - [Architectural diagrams](./docs/flow.md)
- [Project structure](crates/readme.md) - [Project structure](./crates/readme.md)
## Goals ## Goals