Acquires the semaphore. Also, the first execution of this method retrieves the semaphore by name and stores it locally.
<p>
This method is called when the task is entered.
483133
@Override
	public void start () {
		if (semaphore == null) {
			semaphore = NonBlockingSemaphoreRepository.getSemaphore(name);
		}
		semaphoreAcquired = semaphore.acquire();
		super.start();
	}
230111
@Override
    public T get(final String _name)
    {
        if (!hasEntries()) {
            initialize(AbstractAutomaticCache.class);
        }
        return getCache4Name().get(_name);
    }
1036697
public void initialize() {

        if (m_taskFuture != null) {
            m_taskFuture.cancel(false);
            m_taskFuture = null;
        }
        reload();
        m_taskFuture = OpenCms.getExecutor().scheduleWithFixedDelay(
            this::performUpdate,
            UPDATE_DELAY_MILLIS,
            UPDATE_DELAY_MILLIS,
            TimeUnit.MILLISECONDS);

    }
877184
public void release(T element) {
    try {
      if (recycle(element)) {
        elements.add(element);
      }
    } finally {
      semaphore.release();
    }
  }
360144
private final void initializeSyncQueue() {
        Node h;
        if (U.compareAndSwapObject(this, HEAD, null, (h = new Node())))
            tail = h;
    }
588074
@Override
	public final Void get() throws InterruptedException, ExecutionException {
		block(0);
		if (!isUnblocked()) throw new InterruptedException();
		if (hasError()) throw new ExecutionException(error);
		if (isCancelled()) throw new ExecutionException(cancelled);
		return null;
	}
1286721
public function acquire()
    {
        $isAcquired = $this->lock->acquireLock($this->timeout->getValue());

        if (!$isAcquired) {
            throw new LockingException('Lock cannot be acquired.', 1438871269);
        }
    }
863800
public Future<T> backgroundTaskFinished(final Callable<T> cleanupTask) {
      QueueingTask futureTask = null;
      if (cleanupTask != null) {
         if (trace) log.tracef("Background task finished, executing cleanup task");
         futureTask = new QueueingTask(cleanupTask);
         executor.execute(futureTask);
      } else {
         semaphore.release();
         if (trace) log.tracef("Background task finished, available permits %d", semaphore.availablePermits());
         executeFront();
      }
      return futureTask;
   }
446259
public boolean handleNextTask() {
		Runnable task = this.getNextTask();

		if (task != null) {
			synchronized (this.tasksReachesZero) {
				this.runningTasks++;
			}
			try {
				task.run();
			} catch (Throwable t) {
				t.printStackTrace();
			}

			synchronized (this.tasksReachesZero) {
				this.runningTasks--;
				if (this.runningTasks == 0) {
					this.tasksReachesZero.notifyAll();
				}
			}

			synchronized (task) {
				task.notifyAll();
			}
			return true;
		}
		return false;
	}
1189433
def acquire_write(self):
        
        self.monitor.acquire()
        while self.rwlock != 0:
            self.writers_waiting += 1
            self.writers_ok.wait()
            self.writers_waiting -= 1
        self.rwlock = -1
        self.monitor.release()
22709
public synchronized void execute( AsyncTask task ) throws JMSException
	{		
		AsyncTaskProcessorThread thread = threadPool.borrow(); // Dispatch using new borrowed thread
		if (thread != null)
		{
			thread.setTask(task);
			thread.execute();
		}
		else
		{
			// All threads are busy ...
			
			if (task.isMergeable())
			{
				if (!taskSet.add(task))
					return; // Already queued
			}
			
			// Enqueue task
			taskQueue.add(task);
		}
	}
1065882
@Override
    public final void run() {
        for (; ; ) {
            final BaasHandler<?> curr = suspendableHandler.get();
            // at this stage we are in the callback thread of execution
            // we get the current handler and choose the state to reach
            if (curr == Signal.COMMITTED) {
                //the callback has already run
                // really we don't have to make any work
                return;
            }

            final BaasHandler<?> target;
            if (curr == Signal.SUSPENDED || curr == Signal.DELIVERED) {
                //if the current state is SUSPENDED the target state
                //to reach is DELIVERED
                //handlers in DELIVERED state won't change and remain the same
                //so for both the cases the target state would be
                // DELIVERED and there would be no more work to do
                target = Signal.DELIVERED;
            } else {
                // we have a real handler to execute
                // and we need to commit the execution
                target = Signal.COMMITTED;
            }

            if (suspendableHandler.compareAndSet(curr, target)) {
                //at this point the transition is completed
                //if the target we reached is COMMITTED than we have
                //to execute the callback and cleanup the dispatcher
                if (target == Signal.COMMITTED) {
                    if (curr != null) {
                        ((BaasHandler<R>) curr).handle(result);
                    }
                    finish();
                }
                return;
            }
        }
    }
362773
public Pair<ExecutionReference, ExecutableFlow> fetchHead()
      throws InterruptedException {
    final Pair<ExecutionReference, ExecutableFlow> pair = this.queuedFlowList.take();
    if (pair != null && pair.getFirst() != null) {
      this.queuedFlowMap.remove(pair.getFirst().getExecId());
    }
    return pair;
  }
903838
public void acquire() 
    { 
        if (_hasAcquired)
            return;

        // Deliver the onAcquire event to registered listeners
        for (ResourceEvents resourceListener : _listeners)
            resourceListener.onAcquire();

        // Register this ResourceContext with associated container context
        _containerContext.addResourceContext(this, _bean);

        // Set the flag to indicate resources have been acquired.
        _hasAcquired = true;
    }
1018000
public final void acquire(long timeout) throws RuntimeException {
		synchronized (this.LOCK) {
			long start = System.currentTimeMillis();

			while (this.owner != null) {
				if (this.owner.get() == Thread.currentThread()) {
					this.acquire++;

					return;
				}

				try {
					if (timeout == -1) {
						this.LOCK.wait();
					} else {
						this.LOCK.wait(timeout);
					}
				} catch (InterruptedException e) {
					//
				}

				long end = System.currentTimeMillis();

				if ((this.owner != null) && (timeout != -1)
						&& ((end - start) >= timeout)) {
					throw new RuntimeException("TimeoutException");
				}
			}

			this.owner = new WeakReference(Thread.currentThread());
			this.acquire++;
		}
	}
149842
protected TryableSemaphore getExecutionSemaphore() {
        if (properties.executionIsolationStrategy().get() == ExecutionIsolationStrategy.SEMAPHORE) {
            if (executionSemaphoreOverride == null) {
                TryableSemaphore _s = executionSemaphorePerCircuit.get(commandKey.name());
                if (_s == null) {
                    // we didn't find one cache so setup
                    executionSemaphorePerCircuit.putIfAbsent(commandKey.name(), new TryableSemaphoreActual(properties.executionIsolationSemaphoreMaxConcurrentRequests()));
                    // assign whatever got set (this or another thread)
                    return executionSemaphorePerCircuit.get(commandKey.name());
                } else {
                    return _s;
                }
            } else {
                return executionSemaphoreOverride;
            }
        } else {
            // return NoOp implementation since we're not using SEMAPHORE isolation
            return TryableSemaphoreNoOp.DEFAULT;
        }
    }
1107508
def acquire(self, timeout=None):
        
        green = getcurrent()
        parent = green.parent
        if parent is None:
            raise MustBeInChildGreenlet('GreenLock.acquire in main greenlet')

        if self._local.locked:
            future = create_future(self._loop)
            self._queue.append(future)
            parent.switch(future)

        self._local.locked = green
        return self.locked()