Lines Matching refs:handle
273 Deleter* deleter, Cache::Handle** handle,
280 bool Ref(Cache::Handle* handle) override;
281 bool Release(Cache::Handle* handle, bool force_erase = false) override;
308 bool Unref(CacheHandle* handle, bool set_usage, CleanupContext* context);
315 bool UnsetInCache(CacheHandle* handle, CleanupContext* context);
322 void RecycleHandle(CacheHandle* handle, CleanupContext* context);
387 for (auto& handle : list_) { in ~ClockCacheShard() local
388 uint32_t flags = handle.flags.load(std::memory_order_relaxed); in ~ClockCacheShard()
390 if (handle.deleter != nullptr) { in ~ClockCacheShard()
391 (*handle.deleter)(handle.key, handle.value); in ~ClockCacheShard()
393 delete[] handle.key.data(); in ~ClockCacheShard()
411 for (auto& handle : list_) { in ApplyToAllCacheEntries() local
414 uint32_t flags = handle.flags.load(std::memory_order_relaxed); in ApplyToAllCacheEntries()
416 callback(handle.value, handle.charge); in ApplyToAllCacheEntries()
424 void ClockCacheShard::RecycleHandle(CacheHandle* handle, in RecycleHandle() argument
427 assert(!InCache(handle->flags) && CountRefs(handle->flags) == 0); in RecycleHandle()
428 context->to_delete_key.push_back(handle->key.data()); in RecycleHandle()
429 context->to_delete_value.emplace_back(*handle); in RecycleHandle()
430 size_t total_charge = handle->CalcTotalCharge(metadata_charge_policy_); in RecycleHandle()
431 handle->key.clear(); in RecycleHandle()
432 handle->value = nullptr; in RecycleHandle()
433 handle->deleter = nullptr; in RecycleHandle()
434 recycle_.push_back(handle); in RecycleHandle()
439 for (const CacheHandle& handle : context.to_delete_value) { in Cleanup() local
440 if (handle.deleter) { in Cleanup()
441 (*handle.deleter)(handle.key, handle.value); in Cleanup()
450 auto handle = reinterpret_cast<CacheHandle*>(h); in Ref() local
452 uint32_t flags = handle->flags.load(std::memory_order_relaxed); in Ref()
456 if (handle->flags.compare_exchange_weak(flags, flags + kOneRef, in Ref()
461 size_t total_charge = handle->CalcTotalCharge(metadata_charge_policy_); in Ref()
470 bool ClockCacheShard::Unref(CacheHandle* handle, bool set_usage, in Unref() argument
473 handle->flags.fetch_or(kUsageBit, std::memory_order_relaxed); in Unref()
478 uint32_t flags = handle->flags.fetch_sub(kOneRef, std::memory_order_acq_rel); in Unref()
482 size_t total_charge = handle->CalcTotalCharge(metadata_charge_policy_); in Unref()
487 RecycleHandle(handle, context); in Unref()
493 bool ClockCacheShard::UnsetInCache(CacheHandle* handle, in UnsetInCache() argument
500 handle->flags.fetch_and(~kInCacheBit, std::memory_order_acq_rel); in UnsetInCache()
503 RecycleHandle(handle, context); in UnsetInCache()
508 bool ClockCacheShard::TryEvict(CacheHandle* handle, CleanupContext* context) { in TryEvict() argument
511 if (handle->flags.compare_exchange_strong(flags, 0, std::memory_order_acquire, in TryEvict()
514 table_.erase(CacheKey(handle->key, handle->hash)); in TryEvict()
516 RecycleHandle(handle, context); in TryEvict()
519 handle->flags.fetch_and(~kUsageBit, std::memory_order_relaxed); in TryEvict()
582 CacheHandle* handle = nullptr; in Insert() local
584 handle = recycle_.back(); in Insert()
588 handle = &list_.back(); in Insert()
591 handle->key = key; in Insert()
592 handle->hash = hash; in Insert()
593 handle->value = value; in Insert()
594 handle->charge = charge; in Insert()
595 handle->deleter = deleter; in Insert()
597 handle->flags.store(flags, std::memory_order_relaxed); in Insert()
604 table_.insert(HashTable::value_type(CacheKey(key, hash), handle)); in Insert()
609 return handle; in Insert()
621 CacheHandle* handle = Insert(key_copy, hash, value, charge, deleter, in Insert() local
625 if (handle == nullptr) { in Insert()
628 *out_handle = reinterpret_cast<Cache::Handle*>(handle); in Insert()
640 CacheHandle* handle = accessor->second; in Lookup() local
644 if (!Ref(reinterpret_cast<Cache::Handle*>(handle))) { in Lookup()
650 if (hash != handle->hash || key != handle->key) { in Lookup()
652 Unref(handle, false, &context); in Lookup()
657 return reinterpret_cast<Cache::Handle*>(handle); in Lookup()
662 CacheHandle* handle = reinterpret_cast<CacheHandle*>(h); in Release() local
663 bool erased = Unref(handle, true, &context); in Release()
665 erased = EraseAndConfirm(handle->key, handle->hash, &context); in Release()
683 CacheHandle* handle = accessor->second; in EraseAndConfirm() local
685 erased = UnsetInCache(handle, context); in EraseAndConfirm()
695 for (auto& handle : list_) { in EraseUnRefEntries() local
696 UnsetInCache(&handle, &context); in EraseUnRefEntries()
728 void* Value(Handle* handle) override { in Value() argument
729 return reinterpret_cast<const CacheHandle*>(handle)->value; in Value()
732 size_t GetCharge(Handle* handle) const override { in GetCharge()
733 return reinterpret_cast<const CacheHandle*>(handle)->charge; in GetCharge()
736 uint32_t GetHash(Handle* handle) const override { in GetHash()
737 return reinterpret_cast<const CacheHandle*>(handle)->hash; in GetHash()