Package java.util.concurrent.locks

Examples of java.util.concurrent.locks.ReentrantLock.lockInterruptibly()


    if (guard.monitor != this) {
      throw new IllegalMonitorStateException();
    }
    final ReentrantLock lock = this.lock;
    boolean signalBeforeWaiting = lock.isHeldByCurrentThread();
    lock.lockInterruptibly();

    boolean satisfied = false;
    try {
      if (!guard.isSatisfied()) {
        await(guard, signalBeforeWaiting);
View Full Code Here


  public boolean enterIfInterruptibly(Guard guard) throws InterruptedException {
    if (guard.monitor != this) {
      throw new IllegalMonitorStateException();
    }
    final ReentrantLock lock = this.lock;
    lock.lockInterruptibly();

    boolean satisfied = false;
    try {
      return satisfied = guard.isSatisfied();
    } finally {
View Full Code Here

   */
  @Override
  public boolean readWait(final TimeUnit unit, final long time,
                          final OutputStream outputStream, final BufferColor bufferColor) throws IOException, InterruptedException {
    final ReentrantLock lock = bufferColor.getLock();
    lock.lockInterruptibly();
    long nanos = unit.toNanos(time);

    try {
      for (; ; ) {
        long read =  bufferColor.sequence.get();
View Full Code Here

   */
  @Override
  public boolean readWait(TimeUnit unit, long time, OutputStream outputStream, final BufferColor bufferColor,
                          BufferCallback callback) throws IOException, InterruptedException {
    final ReentrantLock lock = bufferColor.lock;
    lock.lockInterruptibly();

    try {
      long nanos = time == -1 ? 1 : unit.toNanos(time);

      callback.before(outputStream);
View Full Code Here

    public E take() throws InterruptedException {
        E x;
        int c = -1;
        final AtomicInteger count = this.count;
        final ReentrantLock takeLock = this.takeLock;
        takeLock.lockInterruptibly();
        try {
            try {
                while (count.get() == 0)
                    notEmpty.await();
            } catch (InterruptedException ie) {
View Full Code Here

     * Inserts the specified element at the tail of this queue, waiting for space to become available if the queue is
     * full. Invoked only through {@link Buffer.BufferInputPort} instances.
     */
    private void put(E e) throws InterruptedException {
        final ReentrantLock lock = this.lock;
        lock.lockInterruptibly();
        try {
            while (count == items.length && !closed)
                notFull.await();
            if (closed)
                return; //If buffer is closed drop input object
View Full Code Here

     * @throws InterruptedException
     */
    @Override
    public E take() throws InterruptedException {
        final ReentrantLock lock = this.lock;
        lock.lockInterruptibly();
        try {
            while (count == 0 && !closed)
                notEmpty.await();
            if (closed && count == 0)
                return null;
View Full Code Here

            return;
        }

        final ReentrantLock lock = this.lock;
        try {
            lock.lockInterruptibly();
        } catch (InterruptedException e) {
            throw new SQLException("interrupt", e);
        }

        boolean init = false;
View Full Code Here

   */
  @Override
  public boolean readWait(final TimeUnit unit, final long time,
                          final OutputStream outputStream, final BufferColor bufferColor) throws IOException, InterruptedException {
    final ReentrantLock lock = bufferColor.getLock();
    lock.lockInterruptibly();

    long nanos = unit.toNanos(time);

    try {

View Full Code Here

   */
  @Override
  public boolean readWait(TimeUnit unit, long time, OutputStream outputStream, final BufferColor bufferColor,
                          BufferCallback callback) throws IOException, InterruptedException {
    final ReentrantLock lock = bufferColor.lock;
    lock.lockInterruptibly();

    long nanos = time == -1 ? 1 : unit.toNanos(time);

    try {
      callback.before(outputStream);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.