To call when a thread wants to enter read mode.
If the lock point is used in write mode, this method will return a SynchronizationPoint unblocked when read can start.
331072
public SynchronizationPoint<NoException> startReadAsync(boolean returnNullIfReady) {
		SynchronizationPoint<NoException> sp;
		synchronized (this) {
			if (!writer) {
				// nobody is writing, we can read
				readers++;
				return returnNullIfReady ? null : new SynchronizationPoint<>(true);
			}
			// if someone is writing, we need to wait
			if (readerWaiting == null)
				readerWaiting = new SynchronizationPoint<NoException>();
			sp = readerWaiting;
			readers++;
		}
		return sp;
	}
274064
public int read() throws IOException {
        synchronized (lock) {
            ensureOpen();
            if (pos < buf.length)
                return buf[pos++];
            else
                return super.read();
        }
    }
1131265
public boolean lock(boolean shared, boolean block)
  {
    if (shared && !_canRead) {
      // Invalid request for a shared "read" lock on a write only stream.

      return false;
    }

    if (!shared && !_canWrite) {
      // Invalid request for an exclusive "write" lock on a read only stream.

      return false;
    }

    return true;
  }
509688
public boolean getReadAhead()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
        {
            SibTr.entry(tc, "getReadAhead");
            SibTr.exit(tc, "getReadAhead", Boolean.valueOf(_enableReadAhead));
        }

        return _enableReadAhead;
    }
1323290
boolean detectDeadlock(Locker acquirer, Lock l, int mode) {

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "detectDeadlock", new Object[] { acquirer, l,
                                                         modeStrs[mode] });
        }

        boolean result = false;

        //----------------------------------------------------------------
        // Iterate through the holders of the given lock and determine if
        // any of them are waiting on a lock held by the requestor. If
        // any of them are then a deadlock exists.
        //----------------------------------------------------------------

        Enumeration holders = l.getHolders();
        while (holders.hasMoreElements()) {
            if (lockerWaitingOn((Locker) holders.nextElement(), acquirer)) {
                result = true;
                break;
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "detectDeadlock:" + result);
        }
        return result;

    }
426472
public ISynchronizationPoint<IOException> end() {
		while (!context.isEmpty())
			closeElement();
		ISynchronizationPoint<IOException> write = writer.flush();
		if (!write.isUnblocked()) {
			SynchronizationPoint<IOException> sp = new SynchronizationPoint<>();
			write.listenInline(() -> { output.flush().listenInline(sp); }, sp);
			return sp;
		}
		if (write.hasError())
			return write;
		return output.flush();
	}
611208
public boolean isSyncCurrentPosition(int syncmode) throws BitstreamException
	{
		int read = readBytes(syncbuf, 0, 4);
		int headerstring = ((syncbuf[0] << 24) & 0xFF000000) | ((syncbuf[1] << 16) & 0x00FF0000) | ((syncbuf[2] << 8) & 0x0000FF00) | ((syncbuf[3] << 0) & 0x000000FF);

		try
		{
			source.unread(syncbuf, 0, read);
		}
		catch (IOException ex)
		{
		}

		boolean sync = false;
		switch (read)
		{
			case 0:
				sync = true;
				break;
			case 4:
				sync = isSyncMark(headerstring, syncmode, syncword);
				break;
		}

		return sync;
	}
100312
public void writeLocked (@Nonnull final Runnable aRunnable)
  {
    writeLock ().lock ();
    try
    {
      aRunnable.run ();
    }
    finally
    {
      writeLock ().unlock ();
    }
  }
690643
protected void synchronizeOutlinePage(INode element) {
		// TODO: don't search for mutexes
		if (element instanceof AMutexSyncDefinition)
			return;
		if (element instanceof ABlockSimpleBlockStm)
			return;

		try {
			synchronizeOutlinePage(element, false);// true
		} catch (Exception e) {

		}
	}
239240
def read(self, timeout=None):
        '''
        
        '''
        # If currently locked, another greenlet is trying to read, so yield
        # control and then return none. Required if a Connection is configured
        # to be synchronous, a sync callback is trying to read, and there's
        # another read loop running read_frames. Without it, the run loop will
        # release the lock but then immediately acquire it again. Yielding
        # control in the reading thread after bytes are read won't fix
        # anything, because it's quite possible the bytes read resulted in a
        # frame that satisfied the synchronous callback, and so this needs to
        # return immediately to first check the current status of synchronous
        # callbacks before attempting to read again.
        if self._read_lock.locked():
            self._read_wait.wait(timeout)
            return None

        self._read_lock.acquire()
        try:
            return super(GeventTransport, self).read(timeout=timeout)
        finally:
            self._read_lock.release()
            self._read_wait.set()
            self._read_wait.clear()
251623
public void setLocked(boolean locked) {
		if (ap == null) {
			return;
		}
		ap.setLocked(locked);
		btnPin.setVisible(! locked);
		if (!ap.isPinned()) {
			// Wont be visible if its pinned
			btnClose.setVisible(! locked);
		}
	}
977113
protected VirtualConnection startResponseRead() {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "startResponseRead");
        }
        HttpInvalidMessageException inv = checkRequestValidity();
        if (null != inv) {
            getAppWriteCallback().error(getVC(), inv);
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
                Tr.exit(tc, "startResponseRead: error");
            }
            return null;
        }
        // check whether read-ahead is enabled. Bypass this code once the
        // init() method has been called (d264854) and continue as normal
        if (isReadAheadEnabled() && READ_STATE_TIME_RESET != getReadState()) {
            // read ahead is active

            int state = CALLBACK_STATE_IDLE;
            // grab the read-ahead states in a sync block to avoid timing windows
            // with the callback kicking in at the same time
            synchronized (this.stateSyncObject) {
                state = getCallbackState();
                setReadState(READ_STATE_ASYNC);
            }

            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Async response read, callback state: " + state);
            }
            switch (state) {
                case (CALLBACK_STATE_COMPLETE):
                    // read-ahead has already completed successfully, start the
                    // parse logic now
                    readAsyncResponse();
                    break;
                case (CALLBACK_STATE_ERROR):
                    // read-ahead already hit an error, trigger that path now
                    setPersistent(false);
                    reConnect(getVC(), this.readException);
                    break;
                case (CALLBACK_STATE_PENDING):
                    // read-ahead is still going on
                    break;
                default:
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "Unexpected state (" + state + ") during async readahead");
                    }
                    setPersistent(false);
                    reConnect(getVC(), new IOException("Read-ahead state failure"));
                    break;
            }
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
                Tr.exit(tc, "startResponseRead: read-ahead");
            }
            return null;
        }

        // When we get here, then the final write of the request has finished
        // and we need to tell the app channel of that IF the temp response
        // reads have been triggered. We will not read for a response here as
        // the app channel is using readNextResponse() for that path.
        // LI4335 - early reads also avoid starting read here
        if (this.bEarlyReads || this.bTempResponsesUsed) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
                Tr.exit(tc, "startResponseRead: temp resp env");
            }
            getAppWriteCallback().complete(getVC());
            return null;
        }

        // otherwise start the read for the response now...
        getResponseImpl();
        readAsyncResponse();

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "startResponseRead");
        }
        return null;
    }
1185790
public int take() {

        // non volatile read  ( which is quicker )
        final int readLocation = this.consumerReadLocation;

        // sets the nextReadLocation my moving it on by 1, this may cause it it wrap back to the start.
        final int nextReadLocation = blockForReadSpace(readLocation);

        // purposely not volatile as the read memory barrier occurred above when we read 'writeLocation'
        final int value = data[readLocation];

        setReadLocation(nextReadLocation);

        return value;

    }
782560
public Optional<LockResource> tryGet(K key, LockMode mode) {
    ValNode valNode = getValNode(key);
    ReentrantReadWriteLock lock = valNode.mValue;
    Lock innerLock;
    switch (mode) {
      case READ:
        innerLock = lock.readLock();
        break;
      case WRITE:
        innerLock = lock.writeLock();
        break;
      default:
        throw new IllegalStateException("Unknown lock mode: " + mode);
    }
    if (!innerLock.tryLock()) {
      return Optional.empty();
    }
    return Optional.of(new RefCountLockResource(innerLock, false, valNode.mRefCount));
  }
36310
private static boolean tryReadLockMillis(long address, long timeInMillis, boolean interruptible)
            throws InterruptedException {
        long lastTime = System.currentTimeMillis();
        do {
            if (LOCK.tryReadLock(A, null, address + LOCK_OFFSET))
                return true;
            checkInterrupted(interruptible);
            ThreadHints.onSpinWait();
            long now = System.currentTimeMillis();
            if (now != lastTime) {
                lastTime = now;
                timeInMillis--;
            }
        } while (timeInMillis >= 0);
        return false;
    }
472833
private boolean processLockingMechanism() throws JournalException {
        boolean locked;
        if (lockRequestedFile.exists()) {
            try {
                if (!lockAcceptedFile.exists()) {
                    lockAcceptedFile.createNewFile();
                }
            } catch (IOException e) {
                throw new JournalException("Unable to create 'Lock Accepted' file at '"
                        + lockAcceptedFile.getPath() + "'");
            }
            locked = true;
        } else {
            if (lockAcceptedFile.exists()) {
                lockAcceptedFile.delete();
            }
            locked = false;
        }

        if (locked && !wasLocked) {
            recoveryLog.log("Lock request detected: "
                    + lockRequestedFile.getPath() + ", Lock accepted: "
                    + lockAcceptedFile.getPath());
        } else if (wasLocked && !locked) {
            recoveryLog.log("Lock request removed: "
                    + lockRequestedFile.getPath());
        }

        wasLocked = locked;
        return locked;
    }
245010
public synchronized boolean lock() throws KeeperException, InterruptedException {
        if (isClosed()) {
            return false;
        }
        ensurePathExists(dir);

        return (Boolean) retryOperation(zop);
    }