File tree Expand file tree Collapse file tree
cachelib/interface/components Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717#include " cachelib/interface/components/FlashCacheComponent.h"
1818
1919#include " cachelib/common/Time.h"
20+ #include " cachelib/interface/utils/CoroFiberAdapter.h"
2021
2122using namespace facebook ::cachelib::navy;
2223
@@ -130,6 +131,17 @@ class FlashCacheItem : public CacheItem {
130131 }
131132}
132133
134+ template <typename FuncT, typename ReturnT, typename CleanupFuncT>
135+ folly::coro::Task<ReturnT> FlashCacheComponent::onWorkerThread (
136+ FuncT&& func, CleanupFuncT&& cleanup) {
137+ XDCHECK (!cache_->regionManager_ .isOnWorker ())
138+ << " Calling public APIs from a worker thread is unsupported" ;
139+ co_return co_await utils::onWorkerThread (
140+ cache_->regionManager_ .getNextWorker (),
141+ std::forward<FuncT>(func),
142+ std::forward<CleanupFuncT>(cleanup));
143+ }
144+
133145const std::string& FlashCacheComponent::getName () const noexcept {
134146 return name_;
135147}
Original file line number Diff line number Diff line change 1717#pragma once
1818
1919#include " cachelib/interface/CacheComponent.h"
20- #include " cachelib/interface/utils/CoroFiberAdapter.h"
2120#include " cachelib/navy/block_cache/BlockCache.h"
2221
2322namespace facebook ::cachelib::interface {
@@ -74,14 +73,7 @@ class FlashCacheComponent : public CacheComponent {
7473 typename ReturnT = std::invoke_result_t <FuncT>,
7574 typename CleanupFuncT = std::function<void (ReturnT)>>
7675 folly::coro::Task<ReturnT> onWorkerThread (FuncT&& func,
77- CleanupFuncT&& cleanup = {}) {
78- XDCHECK (!cache_->regionManager_ .isOnWorker ())
79- << " Calling public APIs from a worker thread is unsupported" ;
80- co_return co_await utils::onWorkerThread (
81- cache_->regionManager_ .getNextWorker (),
82- std::forward<FuncT>(func),
83- std::forward<CleanupFuncT>(cleanup));
84- }
76+ CleanupFuncT&& cleanup = {});
8577
8678 using AllocData =
8779 std::tuple<navy::RegionDescriptor, uint32_t , navy::RelAddress>;
You can’t perform that action at this time.
0 commit comments