Meteor - How to implement a FIFO blocking queue?


My application requires a server side FIFO blocking queue with blocking read with timeout (something equivalent to java.util.concurrent.LinkedBlockingQueue). My search in Meteor or other forums has not resulted in anything. Any suggestions will be really appreciated.


Please be more specific about your use case. There are a number of ways to implement this from a simple javascript queue that wraps every passed function with a call to process the next item all the way to a web worker.

Keep in mind that Meteor (and all nodejs applications) are actually single threaded, so no locking or synchronisation constructs are actually needed. If you need it to be truly blocking, then you’d utilize fibers which is something that could be demonstrated.

One example of a simple queue:

function processQueue(){
	if (!this || !(this instanceof processQueue)){
		return new processQueue();
	this.queue = [];
processQueue.prototype = {
	dequeue: function(){
		return this.queue.shift();
	process: function(){
	wrap: function(_func){
		var self = this;
		return new function(){
	enqueue: function(_func){
	processAsync: function(){
		var self = this;

With a little more information, exactly what you need could be engineered.