Browse files

Readme updated

  • Loading branch information...
1 parent 0f60dfc commit 8c6ad0ef5e0979ca70c3420321575157b20fcef2 @Frans-Willem committed Jul 28, 2010
Showing with 45 additions and 0 deletions.
  1. +45 −0 README
@@ -0,0 +1,45 @@
+Why a new Node.js IPC library?
+As of writing, this, there are three libraries available that offer RPC client and server packages:
+- Eric Florenzano's node-jsonrpc
+- Ryan Tomayko's bertrpc
+- James Halliday's dnode
+The first two both have a very verbose syntax, requiring'method',arguments,returnvalue), and offer no way to nest several objects, use objects as arguments, or return functions.
+dnode is a pretty good fit for most cases, but it never cleans up any marshalled functions or objects, and as such the server will not garbage collect anything unless the connection is closed.
+Furthermore, dnode only supports or socket as transport layers, and as such can not be used over (for example) standard input/output.
+Advantages of IPCNode
+- Explicit reference counting, so no lingering objects.
+- Implements the Node.js Stream interface, so you can easily use any transport layer you want.
+- Event when there are no more cross-boundary objects, so connection can be closed gracefully.
+For the whole idea of simple async RPC, I have to thank dnode. Simply defining objects with functions and the ability to simply marshal that to another process is awesome :)
+As for the reference counting, I'll have to thank my Win32 COM background for that :p
+Why reference counting
+Dnode will simply assign an ID to any callback function, and on the other side create a stub function that sends the ID over the line.
+The problem with that approach is that callback functions will stay in memory until the connection is discarded. Normally with a few simple static callback functions, this isn't a big problem.
+However, if you plan on calling in your RPC with anonymous functions, you should note that everytime you call something with an anonymous function, that anonymous function will never be garbage collected.
+With reference counting, the server side can indicate when a callback function is no longer needed, and the client can discard it.
+To make things easier, IPCNode supplies a helper function for two common approaches:
+- IPCNode.sync to convert a normal synchronous function that returns a value to an asynchronous function with an extra callback argument.
+- IPCNode.async to convert a normal asynchronous function with an existing callback function, to one that will keep a reference to that callback function and dispose of it when it's called.
+- Circular objects
+- Combinations of basic objects and callback objects.
+- Proper disposing of unmarshalled Arrays.
+- Make web-browser proof
+- On object creation, send some initial information along the line, to prevent a request command.
+- Getting started
+- Example reference counting

0 comments on commit 8c6ad0e

Please sign in to comment.