| 66 | } |
| 67 | |
| 68 | RegionDescriptor Region::openForRead() { |
| 69 | std::unique_lock l{lock_}; |
| 70 | if (flags_ & kBlockAccess) { |
| 71 | // Region is currently in reclaim, retry later |
| 72 | if (isOnNavyThread()) { |
| 73 | // If we are on fiber, we can just sleep here |
| 74 | cond_.wait(l); |
| 75 | } |
| 76 | return RegionDescriptor{OpenStatus::Retry}; |
| 77 | } |
| 78 | bool physReadMode = false; |
| 79 | if (isFlushedLocked() || !buffer_) { |
| 80 | physReadMode = true; |
| 81 | activePhysReaders_++; |
| 82 | } else { |
| 83 | activeInMemReaders_++; |
| 84 | } |
| 85 | return RegionDescriptor::makeReadDescriptor(OpenStatus::Ready, regionId_, |
| 86 | physReadMode); |
| 87 | } |
| 88 | |
| 89 | std::unique_ptr<Buffer> Region::detachBuffer() { |
| 90 | std::unique_lock l{lock_}; |