Skip to content

Commit 8ef6864

Browse files
rlyerlymeta-codesync[bot]
authored andcommitted
Move FCC::onWorkerThread into .cpp
Summary: We don't need this in the header, move it to the source instead. Reduces the visible interface and possibly helps w/ compilation times. Reviewed By: AlnisM Differential Revision: D91154246 fbshipit-source-id: ee177f92905eea4cd629e40e21cafbdae3f6c054
1 parent d1cc7e5 commit 8ef6864

2 files changed

Lines changed: 13 additions & 9 deletions

File tree

cachelib/interface/components/FlashCacheComponent.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "cachelib/interface/components/FlashCacheComponent.h"
1818

1919
#include "cachelib/common/Time.h"
20+
#include "cachelib/interface/utils/CoroFiberAdapter.h"
2021

2122
using 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+
133145
const std::string& FlashCacheComponent::getName() const noexcept {
134146
return name_;
135147
}

cachelib/interface/components/FlashCacheComponent.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
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

2322
namespace 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>;

0 commit comments

Comments
 (0)