This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use axum::{ | |
extract::ws::{Message, WebSocket, WebSocketUpgrade}, | |
response::IntoResponse, | |
routing::get, | |
Router, | |
}; | |
use once_cell::sync::Lazy; | |
use std::{future::Future, net::SocketAddr, time::Duration}; | |
use tokio::{ | |
io::{AsyncReadExt, AsyncWriteExt}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// | |
/// ## Examples | |
/// ``` | |
/// enum Foo { | |
/// Path(String), | |
/// Count(usize), | |
/// } | |
/// let foo = Foo::Path(1); | |
/// let f: Option<String> = try_match!(foo, Foo::Path(x)=> x); | |
/// ``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//! Inspired by [this](http://concurrencyfreaks.blogspot.com/2013/08/concurrency-pattern-distributed-cache.html). | |
use cache_padded::CachePadded; | |
use std::sync::atomic::{AtomicUsize, Ordering}; | |
pub struct DistributedCacheLineCounter { | |
counters: Box<[CachePadded<AtomicUsize>]>, | |
num_counters: usize, | |
} |