Create the subqueue to change the default behavior of Lock to semaphore.
502163
def create(self):
        
        self.queue = self.scheduler.queue.addSubQueue(self.priority, LockEvent.createMatcher(self.context, self.key),
                                         maxdefault = self.size, defaultQueueClass = CBQueue.AutoClassQueue.initHelper('locker', subqueuelimit = 1))
640079
private void enqueue(E x) {
        // assert lock.getHoldCount() == 1;
        // assert items[putIndex] == null;
        final Object[] items = this.items;
        items[putIndex] = x;
        if (++putIndex == items.length) putIndex = 0;
        count++;
        notEmpty.signal();
    }
955960
def enqueue(self, method, *args, **kwargs):
        
        if not hasattr(method, "__call__"):
            raise ValueError(
                "{0} has no __call__ member.".format(method.__name__)
            )

        # Prepare the future result object
        future = FutureResult(self._logger)

        # Use a lock, as we might be "resetting" the queue
        with self.__lock:
            # Add the task to the queue
            self._queue.put((method, args, kwargs, future), True, self._timeout)
            self.__nb_pending_task += 1

            if self.__nb_pending_task > self.__nb_threads:
                # All threads are taken: start a new one
                self.__start_thread()

        return future
1267351
private static ThreadFactory createThreadFactory(ThreadFactory threadFactory, String threadNamePrefix,
			Boolean daemon) {
		if (threadFactory != null) {
			return threadFactory;
		}

		if (threadNamePrefix != null) {
			if (daemon != null) {
				return ThreadPoolUtil.buildThreadFactory(threadNamePrefix, daemon);
			} else {
				return ThreadPoolUtil.buildThreadFactory(threadNamePrefix);
			}
		}

		return Executors.defaultThreadFactory();
	}
296803
public static <E> Queue<E> createStack(int initSize) {
		return Collections.asLifoQueue(new ArrayDeque<E>(initSize));
	}
258935
function (options) {
    this.queue = [];
    this.ownerTokenId = null;
    this.options = _.extend({}, AsyncLock.defaultOptions, options);
}
573523
public static <T> Queue<T> newConcurrentQueue(int maxSize) {

        if (maxSize == Integer.MAX_VALUE) {
            return new ConcurrentLinkedDeque<>();
        }

        return maxSize > ARRAY_QUEUE_THRESHOLD ? new LinkedBlockingQueue<>(maxSize) : new ArrayBlockingQueue<>(maxSize);
    }
786035
public static <T> Queue<T> newFixedMpscQueue(int capacity) {
        return hasUnsafe() ? new MpscArrayQueue<T>(capacity) : new MpscAtomicArrayQueue<T>(capacity);
    }
713247
static void acquireAndRelease(Semaphore lock) {
        try {
            lock.acquire();
            lock.release();
        } catch (InterruptedException ex) {
            throw loggedDistributerException(ex, "interruped while waiting for a semaphare");
        }
    }
1298050
@Override
    public Queue createQueue(String queueName) throws JMSRuntimeException {

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "createQueue", new Object[] { queueName });

        Queue queue = null;
        try {
            queue = jmsSession.createQueue(queueName);
        } catch (JMSException jmse) {
            throw (JMSRuntimeException) JmsErrorUtils.getJMS2Exception(jmse, JMSRuntimeException.class);
        } finally {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(this, tc, "createQueue", new Object[] { queue });
        }

        return queue;
    }
764144
@Nullable
    private DedupQueue getQueueReadWrite(String queue, Duration waitDuration) {
        return _ownerGroup.startIfOwner(queue, waitDuration);
    }
617626
function forPropsCallback(subValue, subKey) {
      // exit early to avoid cloning the marker
      if (subValue && subValue.constructor == Marker) {
        return;
      }
      // add objects to the queue
      if (subValue === Object(subValue)) {
        queue[queue.length++] = { 'key': subKey, 'parent': clone, 'source': value };
      }
      // assign non-objects
      else {
        try {
          // will throw an error in strict mode if the property is read-only
          clone[subKey] = subValue;
        } catch(e) { }
      }
    }
320257
function Semaphore(capacity, isFull, priority) {
    if (isNumeric(capacity)) {
        capacity = parseInt(capacity, 10);
        if (capacity <= 0) {
            capacity = Number.POSITIVE_INFINITY;
        }
    } else if (capacity !== Number.POSITIVE_INFINITY) {
        capacity = 1;
    } else {
        isFull = false;
    }

    const _queue = new SortedSet({
        comparator: priorityComparator
    });

    this.id = ++globalCounter;
    this._capacity = capacity;
    this._queue = _queue;
    this._numTokens = isFull ? capacity : 0;
    // eslint-disable-next-line no-magic-numbers
    this.priority = isNumeric(priority) ? parseInt(priority, 10) : 15;
}
747050
public void initAsyncExecutor() {
    if (asyncExecutor == null) {
      DefaultAsyncJobExecutor defaultAsyncExecutor = new DefaultAsyncJobExecutor();

      // Message queue mode
      defaultAsyncExecutor.setMessageQueueMode(asyncExecutorMessageQueueMode);

      // Thread pool config
      defaultAsyncExecutor.setCorePoolSize(asyncExecutorCorePoolSize);
      defaultAsyncExecutor.setMaxPoolSize(asyncExecutorMaxPoolSize);
      defaultAsyncExecutor.setKeepAliveTime(asyncExecutorThreadKeepAliveTime);

      // Threadpool queue
      if (asyncExecutorThreadPoolQueue != null) {
        defaultAsyncExecutor.setThreadPoolQueue(asyncExecutorThreadPoolQueue);
      }
      defaultAsyncExecutor.setQueueSize(asyncExecutorThreadPoolQueueSize);

      // Acquisition wait time
      defaultAsyncExecutor.setDefaultTimerJobAcquireWaitTimeInMillis(asyncExecutorDefaultTimerJobAcquireWaitTime);
      defaultAsyncExecutor.setDefaultAsyncJobAcquireWaitTimeInMillis(asyncExecutorDefaultAsyncJobAcquireWaitTime);

      // Queue full wait time
      defaultAsyncExecutor.setDefaultQueueSizeFullWaitTimeInMillis(asyncExecutorDefaultQueueSizeFullWaitTime);

      // Job locking
      defaultAsyncExecutor.setTimerLockTimeInMillis(asyncExecutorTimerLockTimeInMillis);
      defaultAsyncExecutor.setAsyncJobLockTimeInMillis(asyncExecutorAsyncJobLockTimeInMillis);
      if (asyncExecutorLockOwner != null) {
        defaultAsyncExecutor.setLockOwner(asyncExecutorLockOwner);
      }

      // Reset expired
      defaultAsyncExecutor.setResetExpiredJobsInterval(asyncExecutorResetExpiredJobsInterval);
      defaultAsyncExecutor.setResetExpiredJobsPageSize(asyncExecutorResetExpiredJobsPageSize);

      // Shutdown
      defaultAsyncExecutor.setSecondsToWaitOnShutdown(asyncExecutorSecondsToWaitOnShutdown);

      asyncExecutor = defaultAsyncExecutor;
    }

    asyncExecutor.setProcessEngineConfiguration(this);
    asyncExecutor.setAutoActivate(asyncExecutorActivate);
  }
374492
def add_new(self, command):
        """"""
        self.queue[self.next_key] = command
        self.queue[self.next_key]['status'] = 'queued'
        self.queue[self.next_key]['returncode'] = ''
        self.queue[self.next_key]['stdout'] = ''
        self.queue[self.next_key]['stderr'] = ''
        self.queue[self.next_key]['start'] = ''
        self.queue[self.next_key]['end'] = ''

        self.next_key += 1
        self.write()
1189520
private Node addWaiter(Node mode) {
        Node node = new Node(mode);

        for (;;) {
            Node oldTail = tail;
            if (oldTail != null) {
                U.putObject(node, Node.PREV, oldTail);
                if (compareAndSetTail(oldTail, node)) {
                    oldTail.next = node;
                    return node;
                }
            } else {
                initializeSyncQueue();
            }
        }
    }
873650
function Queue(queueName, accessKey, secretKey, region) {
  if (!(this instanceof Queue)) return new Queue(queueName, accessKey, secretKey, region);
  var self = this;
  Object.defineProperty(this, '_sqs',{enumerable: false, configurable: false, writable: false,
    value: getSQS(accessKey, secretKey, region)});
  function setQueue(name) {
    debug('set queue: ' + name);
    var parsed;
    if (parsed = /([0-9]{12}\/([^\/]+))\/?$/.exec(name)) {
      self._sqs.setQueue('/' + parsed[1] + '/');
      self.name = parsed[2];
      if (self._init) delete self._init;
    } else if (typeof name === 'string') {
      self.name = name;
      Object.defineProperty(self, '_init',{enumerable: false, configurable: true, writable: true,
        value: getQueueURL(self, name).then(setQueue)});
      self.then = self._init.then;
      self.done = self._init.done;
    } else if (name && typeof name === 'object' && typeof name.then === 'function') {
      self.name = name.toString();
      Object.defineProperty(self, '_init',{enumerable: false, configurable: true, writable: true,
        value: name.then(setQueue)});
      self.then = self._init.then;
      self.done = self._init.done;
    } else {
      throw new Error(JSON.stringify(name) + ' is not a valid queue.');
    }
  }
  setQueue(queueName);
}