IndiaQueue

A common phenomenon at most Indian establishments, especially at the counter service “sagar” restaurants, is the use of a data structure I’ve dubbed the “IndiaQueue.” An IndiaQueue has similarities to a classic priority queue, though the method for determining priority is dynamically provided (and can be arbitrarily changed) by the item itself, rather than by the queue or the person servicing the queue. In addition, although this is not a stack, there is a lot of pushing involved.

As opposed to a basic Queue, an IndiaQueue is completely free-threaded by nature, and comes with all of the associated chaos that such functionality entails. In order to understand an IndiaQueue, you must first understand how an IndiaLock works. In a reversal of classic roles, it is up to the items in the queue to acquire an IndiaLock on the vendor in order to be serviced. Taking an IndiaLock involves making eye contact, shoving cash into reach of the vendor, and quickly starting your order. If there is any hesitation in this process, you will never acquire an IndiaLock. Note that an IndiaLock does not always guarantee exclusive access; it is possible that a new, aggressive customer will grab the lock from you and abort your transaction.

The best way to prepare for ordering food or goods in India is to understand how items are processed in an IndiaQueue:

// Dequeue algorithm for an IndiaQueue foreach (Customer customer in vendor.GetCustomersInArmsReach()) { if (customer.IsVisiblyHoldingMoney) { if (customer.IsLoudEnough()) { customer.TakeIndiaLock(vendor) { customer.PlaceTransaction(vendor); } } } }

We’ve been studying the behavior of the IndiaQueue over the past month, and can now routinely hold onto the IndiaLocks that we acquire (though we have not adopted the practice of stealing IndiaLocks from other customers).

3 thoughts on “IndiaQueue”

Leave a Reply

Your email address will not be published. Required fields are marked *