mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-06-19 22:41:04 +00:00
Wire up the cleaned up driver implementation
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user