| 52 | } |
| 53 | |
| 54 | void AsyncDataCacheEntry::setExclusiveToShared(bool cacheable) { |
| 55 | BOLT_CHECK(isExclusive()); |
| 56 | numPins_ = 1; |
| 57 | std::unique_ptr<folly::SharedPromise<bool>> promise; |
| 58 | { |
| 59 | std::lock_guard<std::mutex> l(shard_->mutex()); |
| 60 | // Enter the shard's mutex to make sure a promise is not being added during |
| 61 | // the move. |
| 62 | promise = std::move(promise_); |
| 63 | } |
| 64 | if (promise != nullptr) { |
| 65 | promise->setValue(true); |
| 66 | } |
| 67 | |
| 68 | // The entry may now have other readers, It is safe to do read-only ops like |
| 69 | // integrity and notifying SSD cache of another candidate. |
| 70 | const auto& hook = shard_->cache()->verifyHook(); |
| 71 | if (hook != nullptr) { |
| 72 | hook(*this); |
| 73 | } |
| 74 | |
| 75 | if (cacheable && (ssdFile_ == nullptr) && |
| 76 | (shard_->cache()->ssdCache() != nullptr)) { |
| 77 | auto* ssdCache = shard_->cache()->ssdCache(); |
| 78 | assert(ssdCache); // for lint only. |
| 79 | if (ssdCache->groupStats().shouldSaveToSsd(groupId_, trackingId_)) { |
| 80 | ssdSaveable_ = true; |
| 81 | shard_->cache()->possibleSsdSave(size_); |
| 82 | } |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | void AsyncDataCacheEntry::release() { |
| 87 | BOLT_CHECK_NE(0, numPins_); |