Skip to content

Commit

Permalink
remove register_os_pipe(); remove closure option for register_callback()
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxime2 committed Aug 15, 2019
1 parent bd43640 commit 57b6f67
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use buffer::ReadBuffer;
use libcommon_rs::peer::{Peer, PeerId, PeerList};
use libtransport::errors::{Error, Error::AtMaxVecCapacity, Result};
use libtransport::{Transport, TransportConfiguration};
use os_pipe::PipeWriter;
//use os_pipe::PipeWriter;
use serde::de::DeserializeOwned;
use serde::Serialize;
use std::io;
Expand All @@ -21,8 +21,8 @@ use std::thread::JoinHandle;
pub struct TCPtransportCfg<Data> {
bind_net_addr: String,
channel_pool: Vec<Sender<Data>>,
pipe_pool: Vec<PipeWriter>,
callback_pool: Vec<fn(data: Data) -> bool>,
//pipe_pool: Vec<PipeWriter>,
callback_pool: Vec<fn(Data) -> bool>,
callback_timeout: u64,
quit_rx: Option<Receiver<()>>,
}
Expand All @@ -32,7 +32,7 @@ impl<Data> TransportConfiguration<Data> for TCPtransportCfg<Data> {
TCPtransportCfg {
bind_net_addr: set_bind_net_addr,
channel_pool: Vec::with_capacity(1),
pipe_pool: Vec::with_capacity(1),
//pipe_pool: Vec::with_capacity(1),
callback_pool: Vec::with_capacity(1),
callback_timeout: 100, // 100 millisecond timeout by default
quit_rx: None,
Expand All @@ -46,15 +46,15 @@ impl<Data> TransportConfiguration<Data> for TCPtransportCfg<Data> {
self.channel_pool.push(sender);
Ok(())
}
fn register_os_pipe(&mut self, sender: PipeWriter) -> Result<()> {
// Vec::push() panics when number of elements overflows `usize`
if self.pipe_pool.len() == std::usize::MAX {
return Err(AtMaxVecCapacity);
}
self.pipe_pool.push(sender);
Ok(())
}
fn register_callback(&mut self, callback: fn(data: Data) -> bool) -> Result<()> {
//fn register_os_pipe(&mut self, sender: PipeWriter) -> Result<()> {
// // Vec::push() panics when number of elements overflows `usize`
// if self.pipe_pool.len() == std::usize::MAX {
// return Err(AtMaxVecCapacity);
// }
// self.pipe_pool.push(sender);
// Ok(())
//}
fn register_callback(&mut self, callback: fn(Data) -> bool) -> Result<()> {
// Vec::push() panics when number of elements overflows `usize`
if self.callback_pool.len() == std::usize::MAX {
return Err(AtMaxVecCapacity);
Expand Down

0 comments on commit 57b6f67

Please sign in to comment.