mirror of
https://github.com/aramperes/onetun.git
synced 2025-09-09 11:18:30 -04:00
Cleanup
This commit is contained in:
parent
ccb51fe5f8
commit
3318e30d98
7 changed files with 18 additions and 595 deletions
|
@ -13,6 +13,12 @@ pub struct PortPool {
|
|||
taken: lockfree::set::Set<u16>,
|
||||
}
|
||||
|
||||
impl Default for PortPool {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl PortPool {
|
||||
pub fn new() -> Self {
|
||||
let inner = lockfree::queue::Queue::default();
|
||||
|
@ -28,7 +34,10 @@ impl PortPool {
|
|||
.inner
|
||||
.pop()
|
||||
.with_context(|| "Virtual port pool is exhausted")?;
|
||||
self.taken.insert(port);
|
||||
self.taken
|
||||
.insert(port)
|
||||
.ok()
|
||||
.with_context(|| "Failed to insert taken")?;
|
||||
Ok(port)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue