diff options
| author | Fuwn <[email protected]> | 2026-04-14 09:01:04 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-04-14 09:01:04 +0000 |
| commit | a48462a29ce0a3adbf0c132c28c61194f60d99b0 (patch) | |
| tree | 3d7cda0368c2be310fb9a5bc2661ae7c9daf9c99 /examples/error_handler.rs | |
| parent | chore(license): Relicense under MIT OR Apache-2.0 (diff) | |
| download | archived-windmark-a48462a29ce0a3adbf0c132c28c61194f60d99b0.tar.xz archived-windmark-a48462a29ce0a3adbf0c132c28c61194f60d99b0.zip | |
perf(router)!: Remove AsyncMutex from route and error handlers
Diffstat (limited to 'examples/error_handler.rs')
| -rw-r--r-- | examples/error_handler.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/examples/error_handler.rs b/examples/error_handler.rs index c05f070..7d3ca25 100644 --- a/examples/error_handler.rs +++ b/examples/error_handler.rs @@ -1,18 +1,23 @@ //! `cargo run --example error_handler` +use std::sync::{ + atomic::{AtomicUsize, Ordering}, + Arc, +}; + use windmark::response::Response; #[windmark::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { - let mut error_count = 0; + let error_count = Arc::new(AtomicUsize::new(0)); windmark::router::Router::new() .set_private_key_file("windmark_private.pem") .set_certificate_file("windmark_public.pem") .set_error_handler(move |_| { - error_count += 1; + let count = error_count.fetch_add(1, Ordering::Relaxed) + 1; - println!("{} errors so far", error_count); + println!("{count} errors so far"); Response::permanent_failure("e") }) |