From 77bbab009e30c10714cca03abe1ec16f9028ca04 Mon Sep 17 00:00:00 2001 From: NikVolf Date: Sat, 16 Jul 2016 19:09:14 +0200 Subject: [PATCH] got rid of Arc dispatch --- ethcore/src/client/chain_notify.rs | 3 +-- ethcore/src/client/client.rs | 2 +- ipc/codegen/src/codegen.rs | 6 +++--- ipc/hypervisor/src/service.rs.in | 2 +- ipc/nano/src/lib.rs | 4 ++-- parity/sync/main.rs | 2 +- sync/src/api.rs | 6 +++--- 7 files changed, 12 insertions(+), 13 deletions(-) diff --git a/ethcore/src/client/chain_notify.rs b/ethcore/src/client/chain_notify.rs index 966388f9a..f23f3885b 100644 --- a/ethcore/src/client/chain_notify.rs +++ b/ethcore/src/client/chain_notify.rs @@ -16,7 +16,6 @@ use util::numbers::*; use ipc::{IpcConfig, BinaryConvertError}; -use std::sync::Arc; use std::collections::VecDeque; use std::mem; @@ -44,4 +43,4 @@ pub trait ChainNotify : Send + Sync { } } -impl IpcConfig for Arc { } +impl IpcConfig for ChainNotify { } diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index d35a01be7..3183b0387 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -1015,4 +1015,4 @@ impl MayPanic for Client { } } -impl IpcConfig for Arc { } +impl IpcConfig for BlockChainClient { } diff --git a/ipc/codegen/src/codegen.rs b/ipc/codegen/src/codegen.rs index dcc3082d0..e6744ebb3 100644 --- a/ipc/codegen/src/codegen.rs +++ b/ipc/codegen/src/codegen.rs @@ -591,8 +591,8 @@ fn push_client_implementation( let handshake_item = quote_impl_item!(cx, pub fn handshake(&self) -> Result<(), ::ipc::Error> { let payload = ::ipc::Handshake { - protocol_version: ::std::sync::Arc::<$endpoint>::protocol_version(), - api_version: ::std::sync::Arc::<$endpoint>::api_version(), + protocol_version: $endpoint::protocol_version(), + api_version: $endpoint::api_version(), }; ::ipc::invoke( @@ -834,7 +834,7 @@ fn implement_interface( }; 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(&self, r: &mut R) -> Vec where R: ::std::io::Read { diff --git a/ipc/hypervisor/src/service.rs.in b/ipc/hypervisor/src/service.rs.in index f1949d4ca..f11950bdb 100644 --- a/ipc/hypervisor/src/service.rs.in +++ b/ipc/hypervisor/src/service.rs.in @@ -75,4 +75,4 @@ impl HypervisorService { } } -impl ::ipc::IpcConfig for Arc {} +impl ::ipc::IpcConfig for HypervisorService {} diff --git a/ipc/nano/src/lib.rs b/ipc/nano/src/lib.rs index f835566ed..aaa05555d 100644 --- a/ipc/nano/src/lib.rs +++ b/ipc/nano/src/lib.rs @@ -33,7 +33,7 @@ const POLL_TIMEOUT: isize = 100; const CLIENT_CONNECTION_TIMEOUT: isize = 2500; /// Generic worker to handle service (binded) sockets -pub struct Worker where Arc: IpcInterface { +pub struct Worker where S: IpcInterface { service: Arc, sockets: Vec<(Socket, Endpoint)>, polls: Vec, @@ -116,7 +116,7 @@ pub enum SocketError { RequestLink, } -impl Worker where Arc: IpcInterface { +impl Worker where S: IpcInterface { /// New worker over specified `service` pub fn new(service: &Arc) -> Worker { Worker:: { diff --git a/parity/sync/main.rs b/parity/sync/main.rs index 1e6af664b..e91a8e403 100644 --- a/parity/sync/main.rs +++ b/parity/sync/main.rs @@ -92,7 +92,7 @@ impl Args { } } -fn run_service(addr: &str, stop_guard: Arc, service: Arc) where Arc: IpcInterface { +fn run_service(addr: &str, stop_guard: Arc, service: Arc) where T: IpcInterface { let socket_url = addr.to_owned(); std::thread::spawn(move || { let mut worker = nanoipc::Worker::::new(&service); diff --git a/sync/src/api.rs b/sync/src/api.rs index 4c43d17fc..4400714a6 100644 --- a/sync/src/api.rs +++ b/sync/src/api.rs @@ -19,7 +19,7 @@ use std::sync::Arc; use util::network::{NetworkProtocolHandler, NetworkService, NetworkContext, PeerId, NetworkConfiguration as BasicNetworkConfiguration, NonReservedPeerMode}; use util::{TimerToken, U256, H256, UtilError, Secret, Populatable}; -use ethcore::client::{Client, BlockChainClient, ChainNotify}; +use ethcore::client::{BlockChainClient, ChainNotify}; use io::NetSyncIo; use chain::{ChainSync, SyncStatus}; use std::net::{SocketAddr, AddrParseError}; @@ -149,8 +149,8 @@ impl ChainNotify for EthSync { } } -impl IpcConfig for Arc { } -impl IpcConfig for Arc { } +impl IpcConfig for ManageNetwork { } +impl IpcConfig for SyncProvider { } /// Trait for managing network pub trait ManageNetwork : Send + Sync {