pub struct FinishedWindow<K> { /* private fields */ }Expand description
A memory window for things that belong to finished orders: the cid maps of a connector.
A connector keeps small maps next to its OrderRuntime (cid to instrument, broker id to cid, …).
When an order is final, the connector pushes its cid here. Whatever is older than the
window, or beyond the count limit, comes back from expired, and the connector drops
the entries of those cids. So the maps stay as big as a day of trading and not as the whole life of the
process.
§Examples
use std::time::{Duration, Instant};
use brokapi_runtime::FinishedWindow;
let mut window = FinishedWindow::with_limits(Duration::from_secs(60), 100);
let t0 = Instant::now();
window.push(t0, "a");
window.push(t0 + Duration::from_secs(30), "b");
assert!(window.expired(t0 + Duration::from_secs(59)).is_empty());
assert_eq!(window.expired(t0 + Duration::from_secs(61)), vec!["a"]);
assert_eq!(window.len(), 1);Implementations§
Source§impl<K> FinishedWindow<K>
impl<K> FinishedWindow<K>
Sourcepub fn new() -> Self
pub fn new() -> Self
A window of RETENTION and RETAINED_FINISHED.
Sourcepub fn with_limits(window: Duration, max: usize) -> Self
pub fn with_limits(window: Duration, max: usize) -> Self
A window that keeps a key for window, and at most max keys.
Trait Implementations§
Source§impl<K: Debug> Debug for FinishedWindow<K>
impl<K: Debug> Debug for FinishedWindow<K>
Auto Trait Implementations§
impl<K> Freeze for FinishedWindow<K>
impl<K> RefUnwindSafe for FinishedWindow<K>where
K: RefUnwindSafe,
impl<K> Send for FinishedWindow<K>where
K: Send,
impl<K> Sync for FinishedWindow<K>where
K: Sync,
impl<K> Unpin for FinishedWindow<K>where
K: Unpin,
impl<K> UnsafeUnpin for FinishedWindow<K>
impl<K> UnwindSafe for FinishedWindow<K>where
K: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more