From b04d8196c7496cfdec7cc2d1dfb200e4abdffd28 Mon Sep 17 00:00:00 2001 From: NikVolf Date: Sun, 3 Apr 2016 23:39:49 +0300 Subject: [PATCH] dispatch_buf --- ipc/codegen/src/codegen.rs | 9 +++++++++ ipc/nano/src/lib.rs | 24 +++++++++++++++++++++++- ipc/rpc/src/interface.rs | 4 ++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/ipc/codegen/src/codegen.rs b/ipc/codegen/src/codegen.rs index 166ae87bd..f0c404132 100644 --- a/ipc/codegen/src/codegen.rs +++ b/ipc/codegen/src/codegen.rs @@ -531,6 +531,15 @@ fn implement_interface( _ => vec![] } } + + fn dispatch_buf(&self, method_num: u16, r: &mut R) -> Vec + where R: ::std::io::Read + { + match method_num { + $dispatch_arms + _ => vec![] + } + } } ).unwrap(), dispatch_table)) } diff --git a/ipc/nano/src/lib.rs b/ipc/nano/src/lib.rs index a77ff7f05..166c4ea53 100644 --- a/ipc/nano/src/lib.rs +++ b/ipc/nano/src/lib.rs @@ -14,7 +14,29 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -//! Ethcore implementation of IPC over nanomsg transport +//! IPC over nanomsg transport extern crate ethcore_ipc as ipc; extern crate nanomsg; + +pub use ipc::*; + +use std::sync::*; +use nanomsg::{Socket, Protocol}; + +pub struct Worker where S: IpcInterface { + service: Arc, + sockets: Vec, +} + +impl Worker where S: IpcInterface { + pub fn new(service: Arc, socket_addr: &str) -> Worker { + Worker:: { + service: service.clone(), + sockets: Vec::new(), + } + } + + pub fn work_loop(&mut self) { + } +} diff --git a/ipc/rpc/src/interface.rs b/ipc/rpc/src/interface.rs index 8d67deca3..a55133191 100644 --- a/ipc/rpc/src/interface.rs +++ b/ipc/rpc/src/interface.rs @@ -23,6 +23,10 @@ use std::sync::atomic::*; pub trait IpcInterface { /// reads the message from io, dispatches the call and returns result fn dispatch(&self, r: &mut R) -> Vec where R: Read; + + /// deserialize the payload from the io `r` and invokes method specified by `method_num` + /// (for non-blocking io) + fn dispatch_buf(&self, method_num: u16, r: &mut R) -> Vec where R: Read; } /// serializes method invocation (method_num and parameters) to the stream specified by `w`