Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exposed TIMER_TICK_MILLIS to Settings #237

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
authors = ["Jason Housley <[email protected]>"]
description = "Lightweight, event-driven WebSockets for Rust."
description = "(fork) Lightweight, event-driven WebSockets for Rust."
documentation = "https://ws-rs.org/docs"
keywords = [
"websocket",
Expand All @@ -10,7 +10,7 @@ keywords = [
"web",
]
license = "MIT"
name = "ws"
name = "qws"
readme = "README.md"
repository = "https://github.com/housleyjk/ws-rs"
version = "0.7.9"
Expand Down
3 changes: 1 addition & 2 deletions src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ type Conn<F> = Connection<<F as Factory>::Handler>;

const MAX_EVENTS: usize = 1024;
const MESSAGES_PER_TICK: usize = 256;
const TIMER_TICK_MILLIS: u64 = 100;
const TIMER_WHEEL_SIZE: usize = 1024;
const TIMER_CAPACITY: usize = 65_536;

Expand Down Expand Up @@ -100,7 +99,7 @@ where
pub fn new(factory: F, settings: Settings) -> Handler<F> {
let (tx, rx) = mio::channel::sync_channel(settings.max_connections * settings.queue_size);
let timer = mio_extras::timer::Builder::default()
.tick_duration(Duration::from_millis(TIMER_TICK_MILLIS))
.tick_duration(Duration::from_millis(settings.timer_tick_millis))
.num_slots(TIMER_WHEEL_SIZE)
.capacity(TIMER_CAPACITY)
.build();
Expand Down
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ pub struct Settings {
///
/// Default: false
pub tcp_nodelay: bool,
/// Size of mio's timer each tick in milliseconds.
///
/// Default: 100
pub timer_tick_millis: u64
}

impl Default for Settings {
Expand Down Expand Up @@ -262,6 +266,7 @@ impl Default for Settings {
method_strict: false,
encrypt_server: false,
tcp_nodelay: false,
timer_tick_millis: 100
}
}
}
Expand Down