Skip to content

Commit

Permalink
docs: explain park() loop
Browse files Browse the repository at this point in the history
  • Loading branch information
NotAShelf committed Mar 22, 2024
1 parent 4c2c494 commit cf345c0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ mod tailscale;
mod tray;

use ksni::TrayService;
use std::thread::park;

fn main() {
// initialize logger
Expand All @@ -14,7 +15,11 @@ fn main() {
TrayService::new(crate::tray::menu::SysTray::new()).spawn();

// keep the main thread alive
// NOTE: The documentation for park reads:
// "A call to park does not guarantee that the thread will
// remain parked forever, and callers should be prepared for this possibility."
// hence the loop
loop {
std::thread::park();
park();
}
}

0 comments on commit cf345c0

Please sign in to comment.