got rid of Arc<T> dispatch

This commit is contained in:
NikVolf 2016-07-16 19:09:14 +02:00
parent 8e26977693
commit 77bbab009e
7 changed files with 12 additions and 13 deletions

View File

@ -16,7 +16,6 @@
use util::numbers::*; use util::numbers::*;
use ipc::{IpcConfig, BinaryConvertError}; use ipc::{IpcConfig, BinaryConvertError};
use std::sync::Arc;
use std::collections::VecDeque; use std::collections::VecDeque;
use std::mem; use std::mem;
@ -44,4 +43,4 @@ pub trait ChainNotify : Send + Sync {
} }
} }
impl IpcConfig<ChainNotify> for Arc<ChainNotify> { } impl IpcConfig<ChainNotify> for ChainNotify { }

View File

@ -1015,4 +1015,4 @@ impl MayPanic for Client {
} }
} }
impl IpcConfig<BlockChainClient> for Arc<BlockChainClient> { } impl IpcConfig<BlockChainClient> for BlockChainClient { }

View File

@ -591,8 +591,8 @@ fn push_client_implementation(
let handshake_item = quote_impl_item!(cx, let handshake_item = quote_impl_item!(cx,
pub fn handshake(&self) -> Result<(), ::ipc::Error> { pub fn handshake(&self) -> Result<(), ::ipc::Error> {
let payload = ::ipc::Handshake { let payload = ::ipc::Handshake {
protocol_version: ::std::sync::Arc::<$endpoint>::protocol_version(), protocol_version: $endpoint::protocol_version(),
api_version: ::std::sync::Arc::<$endpoint>::api_version(), api_version: $endpoint::api_version(),
}; };
::ipc::invoke( ::ipc::invoke(
@ -834,7 +834,7 @@ fn implement_interface(
}; };
let ipc_item = quote_item!(cx, let ipc_item = quote_item!(cx,
impl $host_generics ::ipc::IpcInterface<$interface_endpoint> for ::std::sync::Arc<$interface_endpoint> $where_clause { impl $host_generics ::ipc::IpcInterface<$interface_endpoint> for $interface_endpoint $where_clause {
fn dispatch<R>(&self, r: &mut R) -> Vec<u8> fn dispatch<R>(&self, r: &mut R) -> Vec<u8>
where R: ::std::io::Read where R: ::std::io::Read
{ {

View File

@ -75,4 +75,4 @@ impl HypervisorService {
} }
} }
impl ::ipc::IpcConfig<HypervisorService> for Arc<HypervisorService> {} impl ::ipc::IpcConfig<HypervisorService> for HypervisorService {}

View File

@ -33,7 +33,7 @@ const POLL_TIMEOUT: isize = 100;
const CLIENT_CONNECTION_TIMEOUT: isize = 2500; const CLIENT_CONNECTION_TIMEOUT: isize = 2500;
/// Generic worker to handle service (binded) sockets /// Generic worker to handle service (binded) sockets
pub struct Worker<S: ?Sized> where Arc<S>: IpcInterface<S> { pub struct Worker<S: ?Sized> where S: IpcInterface<S> {
service: Arc<S>, service: Arc<S>,
sockets: Vec<(Socket, Endpoint)>, sockets: Vec<(Socket, Endpoint)>,
polls: Vec<PollFd>, polls: Vec<PollFd>,
@ -116,7 +116,7 @@ pub enum SocketError {
RequestLink, RequestLink,
} }
impl<S: ?Sized> Worker<S> where Arc<S>: IpcInterface<S> { impl<S: ?Sized> Worker<S> where S: IpcInterface<S> {
/// New worker over specified `service` /// New worker over specified `service`
pub fn new(service: &Arc<S>) -> Worker<S> { pub fn new(service: &Arc<S>) -> Worker<S> {
Worker::<S> { Worker::<S> {

View File

@ -92,7 +92,7 @@ impl Args {
} }
} }
fn run_service<T: ?Sized + Send + Sync + 'static>(addr: &str, stop_guard: Arc<AtomicBool>, service: Arc<T>) where Arc<T>: IpcInterface<T> { fn run_service<T: ?Sized + Send + Sync + 'static>(addr: &str, stop_guard: Arc<AtomicBool>, service: Arc<T>) where T: IpcInterface<T> {
let socket_url = addr.to_owned(); let socket_url = addr.to_owned();
std::thread::spawn(move || { std::thread::spawn(move || {
let mut worker = nanoipc::Worker::<T>::new(&service); let mut worker = nanoipc::Worker::<T>::new(&service);

View File

@ -19,7 +19,7 @@ use std::sync::Arc;
use util::network::{NetworkProtocolHandler, NetworkService, NetworkContext, PeerId, use util::network::{NetworkProtocolHandler, NetworkService, NetworkContext, PeerId,
NetworkConfiguration as BasicNetworkConfiguration, NonReservedPeerMode}; NetworkConfiguration as BasicNetworkConfiguration, NonReservedPeerMode};
use util::{TimerToken, U256, H256, UtilError, Secret, Populatable}; use util::{TimerToken, U256, H256, UtilError, Secret, Populatable};
use ethcore::client::{Client, BlockChainClient, ChainNotify}; use ethcore::client::{BlockChainClient, ChainNotify};
use io::NetSyncIo; use io::NetSyncIo;
use chain::{ChainSync, SyncStatus}; use chain::{ChainSync, SyncStatus};
use std::net::{SocketAddr, AddrParseError}; use std::net::{SocketAddr, AddrParseError};
@ -149,8 +149,8 @@ impl ChainNotify for EthSync {
} }
} }
impl IpcConfig<ManageNetwork> for Arc<ManageNetwork> { } impl IpcConfig<ManageNetwork> for ManageNetwork { }
impl IpcConfig<SyncProvider> for Arc<SyncProvider> { } impl IpcConfig<SyncProvider> for SyncProvider { }
/// Trait for managing network /// Trait for managing network
pub trait ManageNetwork : Send + Sync { pub trait ManageNetwork : Send + Sync {