Semaphore locking in CommonJS model