Lately I've been hammering on Reflecta, working out bugs and ensuring I have rock solid communications between the host and the Arduino. One issue I recently ran into is when nodejs talks to the Serial Port (AKA Arduino) via the node-serialport library, occasionally it will send the data out of order. Fixing this required me to learn the details of how nodejs buffers data for asynchronous, in order sending. Nodejs leverages part of the nginx source code for handling queues of data in this case -- coded up in ngx-queue.h. ngx-queue.h is a little strange compared to other queues in that you don't 'add your data to the queue entry'. Instead you create a struct containing your data and the queue entry and then add the struct's queue entry to the queue. This is an effective way to make a 'generic' or 'templated' queuing API using simple pointer logic.
Since it took me a few hours to figure out from the source code and example usages inside of nodejs, I figured someone else might benefit from the sample I created while learning so I created a Github Gist of it. To compile, you'll need nodejs, npm, and node-gyp installed since that is the C++ build environment the sample uses. Run 'node-gyp configure' and 'node-gyp build' to compile.