Wire up the cleaned up driver implementation

This commit is contained in:
Omar Abdulla
2025-09-30 13:39:25 +03:00
parent c3c7203af8
commit 8762702560
12 changed files with 450 additions and 827 deletions
+2
View File
@@ -1,9 +1,11 @@
mod identifiers;
mod mode;
mod private_key_allocator;
mod round_robin_pool;
mod version_or_requirement;
pub use identifiers::*;
pub use mode::*;
pub use private_key_allocator::*;
pub use round_robin_pool::*;
pub use version_or_requirement::*;
@@ -0,0 +1,24 @@
use std::sync::atomic::{AtomicUsize, Ordering};
pub struct RoundRobinPool<T> {
next_index: AtomicUsize,
items: Vec<T>,
}
impl<T> RoundRobinPool<T> {
pub fn new(items: Vec<T>) -> Self {
Self {
next_index: Default::default(),
items,
}
}
pub fn round_robin(&self) -> &T {
let current = self.next_index.fetch_add(1, Ordering::SeqCst) % self.items.len();
self.items.get(current).unwrap()
}
pub fn iter(&self) -> impl Iterator<Item = &T> {
self.items.iter()
}
}