This repository has been archived by the owner on Feb 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Home
lhofhansl edited this page Oct 23, 2010
·
29 revisions
RhiNode is a wrapper around Java's NIO implemented in Javascript. The API is heavily inspired by the excellent node.js API.
The aim of this project is not to be a 100% node.js compatible implementation on Rhino (although it might go that way). There are other projects that attempt to do this (one is "rhinode" hosted on github as well).
The implementation is pretty straightforward.
- Buffer management is based on NIO buffers.
- Readbuffers are retrieved from a "pool of bytes" which are never reused (that way a buffer can be passed on and held by a caller). The byte pool is allocated in small 64k chunks.
- Writebuffers are implemented as "ByteBufferOutputstream" (similar to ByteArrayOutputstream, but backed by ByteBuffers).
- The HTTP modules support 1.1 and 1.0 clients and servers.
- The HTTP state management is done as Javascript generator function. This allows for network buffer to be pumped through the generator as data becomes available from the network.
- The FS module currently only simulates Readable/Writable stream. NIO does not have selectable FileChannels, so file streams are always considered readable and writable.
Performance is already pretty good, even though the main event loop and other tight loops are still running in Javascript.
TODO:
-
Optimizations
- Implement tight-loop code in Java
- Implement the event loop in Java
- Cache Http-Parser Generator functions, because they are expensive to create (mostly an issue for HTTP without keep-alive)
- See Benchmarks
-
Test cases
-
Datagram sockets
-
Full FileSystem API
-
Better name? Currently it's a combination of Rhino and Node (not very clever)