void Inode::Close(int openMode, file_cookie* cookie) { TRACE("Inode %p::Close(openMode = %d)\n", this, openMode); MutexLocker locker(RequestLock()); // Notify all currently reading file descriptors ReadRequestList::Iterator iterator = fReadRequests.GetIterator(); while (ReadRequest* request = iterator.Next()) { if (request->Cookie() == cookie) request->Notify(B_FILE_ERROR); } if ((openMode & O_ACCMODE) == O_WRONLY && --fWriterCount == 0) NotifyEndClosed(true); if ((openMode & O_ACCMODE) == O_RDONLY || (openMode & O_ACCMODE) == O_RDWR) { if (--fReaderCount == 0) NotifyEndClosed(false); } if (fWriterCount == 0) { // Notify any still reading writers to stop // TODO: This only works reliable if there is only one writer - we could // do the same thing done for the read requests. fWriteCondition.NotifyAll(B_FILE_ERROR); } if (fReaderCount == 0 && fWriterCount == 0) { fActive = false; fBuffer.DeleteBuffer(); } }
void touchmind::control::DWriteEditControlTextStoreACP::_UnlockDocument() { HRESULT hr; m_fLocked = FALSE; m_dwLockType = 0; if (m_fPendingLockUpgrade) { m_fPendingLockUpgrade = FALSE; RequestLock(TS_LF_READWRITE, &hr); } if (m_fLayoutChanged) { m_fLayoutChanged = FALSE; m_AdviseSink.pTextStoreACPSink->OnLayoutChange(TS_LC_CHANGE, EDIT_VIEW_COOKIE); } }
void Inode::Open(int openMode) { MutexLocker locker(RequestLock()); if ((openMode & O_ACCMODE) == O_WRONLY) fWriterCount++; if ((openMode & O_ACCMODE) == O_RDONLY || (openMode & O_ACCMODE) == O_RDWR) fReaderCount++; if (fReaderCount > 0 && fWriterCount > 0) { TRACE("Inode %p::Open(): fifo becomes active\n", this); fBuffer.CreateBuffer(); fActive = true; // notify all waiting writers that they can start if (fWriteSelectSyncPool) notify_select_event_pool(fWriteSelectSyncPool, B_SELECT_WRITE); fWriteCondition.NotifyAll(); } }