| 329 | } |
| 330 | |
| 331 | folly::coro::Task<Result<FlashCacheComponent::AllocData>> |
| 332 | FlashCacheComponent::allocateImpl(const HashedKey& key, uint32_t valueSize) { |
| 333 | auto ret = co_await onWorkerThread( |
| 334 | [=, this]() { |
| 335 | return cache_->allocateForInsert(key, valueSize, /* canWait */ false); |
| 336 | }, |
| 337 | [this](auto&& result) { |
| 338 | if (result.hasValue()) { |
| 339 | // Successfully allocated Region memory but coroutine was cancelled - |
| 340 | // close the descriptor to release refcount on the Region |
| 341 | auto& [desc, slotSize, _, _2] = result.value(); |
| 342 | cache_->addHole(slotSize); |
| 343 | cache_->regionManager_.close(std::move(desc)); |
| 344 | } |
| 345 | }); |
| 346 | if (ret.hasValue()) { |
| 347 | co_return std::move(ret).value(); |
| 348 | } else { |
| 349 | co_return makeError(Error::Code::ALLOCATE_FAILED, |
| 350 | "could not allocate space in a region"); |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | template <typename CacheItemT> |
| 355 | folly::coro::Task<Result<AllocatedHandle>> FlashCacheComponent::allocateGeneric( |
nothing calls this directly
no test coverage detected