use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize, Default, JsonSchema)]
#[serde(default, deny_unknown_fields)]
pub struct LoopConfig {
pub wait_when_empty: Option<bool>,
#[schemars(range(min = 50))]
pub empty_poll_ms: Option<u64>,
pub wait_when_blocked: Option<bool>,
#[schemars(range(min = 50))]
pub wait_poll_ms: Option<u64>,
#[schemars(range(min = 0))]
pub wait_timeout_seconds: Option<u64>,
pub notify_when_unblocked: Option<bool>,
}
impl LoopConfig {
pub fn merge_from(&mut self, other: Self) {
if other.wait_when_empty.is_some() {
self.wait_when_empty = other.wait_when_empty;
}
if other.empty_poll_ms.is_some() {
self.empty_poll_ms = other.empty_poll_ms;
}
if other.wait_when_blocked.is_some() {
self.wait_when_blocked = other.wait_when_blocked;
}
if other.wait_poll_ms.is_some() {
self.wait_poll_ms = other.wait_poll_ms;
}
if other.wait_timeout_seconds.is_some() {
self.wait_timeout_seconds = other.wait_timeout_seconds;
}
if other.notify_when_unblocked.is_some() {
self.notify_when_unblocked = other.notify_when_unblocked;
}
}
}