index.js
/*
 * consumes a matching message from the queue or blocks and waits for the message to arrive
 * @param criteria {Object}: contains the criteria of the message to be recieved (optional)
 * @return {Any JSON serializable data}: the message's data
 */
consumes a matching message from the queue or blocks and waits for the message to arrive
@param criteria {Object}: contains the criteria of the message to be recieved (optional)
@return {Any JSON serializable data}: the message's data
consumes a matching message from the queue or blocks and waits for the message to arrive @param criteria { Object } : contains the criteria of the message to be recieved ( optional ) @return { Any JSON serializable data } : the message ' s data
function recv(criteria) {
    var default_criteria = {
        from : -1,  
        subject: "-1", 
    };
    var used_criteria = utilis.blend(default_criteria, criteria);
    var queue_size = queue.length;
    for(var i = 0; i < queue_size; i++) {
        var message = queue[i];
        if(utilis.match(used_criteria, message.header)) {
            queue.splice(i, 1);  
            return message.data;
        }
    }
    registered_sync_request = used_criteria;
    return fiber.yield();
}
function recv ( criteria ) { var default_criteria = { from : - 1 , subject : "-1" , } ; var used_criteria = utilis . blend ( default_criteria , criteria ) ; var queue_size = queue . length ; for ( var i = 0 ; i < queue_size ; i ++ ) { var message = queue [ i ] ; if ( utilis . match ( used_criteria , message . header ) ) { queue . splice ( i , 1 ) ; return message . data ; } } registered_sync_request = used_criteria ; return fiber . yield ( ) ; }
consumes a matching message from the queue or blocks and waits for the message to arrive
 @param criteria {Object}: contains the criteria of the message to be recieved (optional)
 @return {Any JSON serializable data}: the message's data
consumes a matching message from the queue or blocks and waits for the message to arrive @param criteria { Object } : contains the criteria of the message to be recieved ( optional ) @return { Any JSON serializable data } : the message ' s data
/*
     * the criteria object may containe:
     * @key from {Number}: the source of the message to be received (any source if ommitted or -1)
     * @key subject {String}: the subject of the message to be received (any subject if omitted or "-1")
     * if the criteria object wasn't provided, a default criteria of any source, any subject will be used
     */ // from any source // with any subject // first check the queue for a message matching the criteria // TODO: come up with a more effcient and scalable implementation for the queue checking // removes the message from the queue // if no matching messsage was found in the queue // register the criteria for upcoming messages // block the execution