[RMI-like-lib] is there any interest in such?

I've been thinking of a library that would bring RMI-like capabilities to C++ (RMI stands for Remote Method Invocation). Primary goal, and differentiating feature, of this library is not to rely on IDL-like compiler, hence no cross-language support either -- if you need that, check out CORBA (www.omg.org) or ICE (http://www.zeroc.com). As an example, I'm going to "implement" client and server sides of a trivial calculator using proposed library. Step 1. Define calculator interface ----------------------------------- // // Operations: add, subtract, multiply and divide // struct add { typedef function2<double, double, double> function_type; }; struct subtract { typedef function2<double, double, double> function_type; }; struct multiply { typedef function2<double, double, double> function_type; }; struct divide { typedef function2<double, double, double> function_type; }; // Calculator interface // typedef interface< operation<sum>, operation<subtract>, operation<multiply>, operation<divide> > calculator_i; Step 2. Client invocation ------------------------- // Construct a proxy to the remote calculator // instance. Arguments to the constructor // describe remote object's location (not shown). // proxy<calculator_i> calculator(...); // Call `subtract' on remote object (call // doesn't block). Returned object implements // Asynchronous Completion Token (or Future) // concept. // act<double> res = call<subtract>(calculator, 12, 43); // Retrieve actual result, or get an exception... // double result = res(); Step 3. Server implementation ----------------------------- // Implement actual calculator. // struct calculator_servant { double sum(double a, double b) { return a + b; } ... // other operations here }; // Instantiate calculator servant // calculator_servant servant; // Create a TCP listener. // tcp_listener listener(...) // Create a stub object that acts as an // adapter between transport and a servant. // stub<calculator_i> calculator(listener); // Install operation handlers. // calculator.register_function<add>(bind(&calculator_servant::sum, ref(servant), _1, _2)); ... // register remaining handlers // Start accepting calls. // calculator.activate(); // Block until exiting. // calculator.wait_for_shutdown(); ... -- end of example] I'm fairly satisfied with the client side, but I'm not so enthusiastic about the server side though. For one, it feels less safe. For example, what if a user forgets to register a "handler" for a particular operation? Any way to enforce this at compile time? Typically, say with CORBA, IDL compiler generates operations as pure virtual functions, so at compile time, the user knows what's left out in her servant. On the other side, it's quite powerful too (being able to "bind" functors to operations, that is). Would that be a problem for you or you'd see it as a good feature? Let me know what you think. Cheers, Slawomir Lisznianski

"Slawomir Lisznianski" wrote:
I've been thinking of a library that would bring RMI-like capabilities to C++ (RMI stands for Remote Method Invocation).
Could you compare your approach to: http://www.codeproject.com/threads/RMI_For_Cpp.asp /Pavel

Pavel Vozenilek wrote:
Could you compare your approach to: http://www.codeproject.com/threads/RMI_For_Cpp.asp
Properties of the proposed library (as compared to "RMI for Cpp"): - no need for macros. - on the server side, interface-operations are bound to functors, at runtime. - interface and operations are expressed in template-metaprogramming style, which may be less familiar (more complex) to developers. - CORBA-like object semantics with support for "transient" instances. For example, when you construct a client-proxy, out of a portable stringified reference, currently URI, you are pointing at a concrete stub/servant instance. If that stub/servant was brought down, your reference is no longer valid and "transient" exception is thrown on any operations against it. In other words, say TCP address and port are not pointing at a servant yet. It takes "instance id", think of it as `this' pointer in C++, to reach a particular servant. Why this is considered important? Because it allows for stateful remote objects. You can construct N-number of instances of the same class of servant, and each one will have a distinguishing reference that the client can call. - abstracted transport layer. Support for transports such as raw TCP, HTTP, or Unix sockets. For example, a single servant could be reached from different transports at the same time without knowing, nor caring, how the request originated. Cheers, Slawomir

Slawomir Lisznianski <slisznianski <at> asyncnet.com> writes:
I've been thinking of a library that would bring RMI-like capabilities to C++ (RMI stands for Remote Method Invocation).
Primary goal, and differentiating feature, of this library is not to rely on IDL-like compiler, hence no cross-language support either -- if you need that, check out CORBA (www.omg.org) or ICE (http://www.zeroc.com).
Jarl Lindrud has done a lot of work on this already - see http://www.codeproject.com/threads/RMI_For_Cpp.asp While it uses boost and mpl techniques extensively it's not quite boost style. I'd be using it extensively but for the fact that it doesn't integrate well with our own code framework.
participants (3)
-
Pavel Vozenilek
-
Simon Carter
-
Slawomir Lisznianski