Skip to content

Commit

Permalink
reduce copies
Browse files Browse the repository at this point in the history
Summary: using move instead

Reviewed By: Gownta

Differential Revision: D63436308

fbshipit-source-id: f03dd93565663b3955019c0162344925fbacc286
  • Loading branch information
Amit Kumar authored and facebook-github-bot committed Oct 17, 2024
1 parent 6e300f3 commit ab576d6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
17 changes: 6 additions & 11 deletions folly/executors/CPUThreadPoolExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ CPUThreadPoolExecutor::CPUThreadPoolExecutor(
Options opt)
: ThreadPoolExecutor(
numThreads.first, numThreads.second, std::move(threadFactory)),
taskQueue_(taskQueue.release()),
taskQueue_(std::move(taskQueue)),
prohibitBlockingOnThreadPools_{opt.blocking} {
setNumThreads(numThreads.first);
if (numThreads.second == 0) {
Expand All @@ -121,16 +121,11 @@ CPUThreadPoolExecutor::CPUThreadPoolExecutor(
std::pair<size_t, size_t> numThreads,
std::shared_ptr<ThreadFactory> threadFactory,
Options opt)
: ThreadPoolExecutor(
numThreads.first, numThreads.second, std::move(threadFactory)),
taskQueue_(makeDefaultQueue()),
prohibitBlockingOnThreadPools_{opt.blocking} {
setNumThreads(numThreads.first);
if (numThreads.second == 0) {
minThreads_.store(1, std::memory_order_relaxed);
}
registerThreadPoolExecutor(this);
}
: CPUThreadPoolExecutor(
numThreads,
makeDefaultQueue(),
std::move(threadFactory),
std::move(opt)) {}

CPUThreadPoolExecutor::CPUThreadPoolExecutor(size_t numThreads, Options opt)
: CPUThreadPoolExecutor(
Expand Down
8 changes: 4 additions & 4 deletions folly/executors/GlobalThreadPoolList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ GlobalThreadPoolList& GlobalThreadPoolList::instance() {

void GlobalThreadPoolList::registerThreadPool(
ThreadPoolListHook* threadPoolId, std::string name) {
globalListImpl_.wlock()->registerThreadPool(threadPoolId, name);
globalListImpl_.wlock()->registerThreadPool(threadPoolId, std::move(name));
}

void GlobalThreadPoolList::unregisterThreadPool(
Expand Down Expand Up @@ -159,9 +159,9 @@ void GlobalThreadPoolList::unregisterThreadPoolThread(
void GlobalThreadPoolListImpl::registerThreadPool(
ThreadPoolListHook* threadPoolId, std::string name) {
PoolInfo info;
info.name = name;
info.name = std::move(name);
info.addr = threadPoolId;
pools_.vector().push_back(info);
pools_.vector().push_back(std::move(info));
}

void GlobalThreadPoolListImpl::unregisterThreadPool(
Expand Down Expand Up @@ -225,7 +225,7 @@ ThreadListHook::~ThreadListHook() {

ThreadPoolListHook::ThreadPoolListHook(std::string name) {
debugger_detail::GlobalThreadPoolList::instance().registerThreadPool(
this, name);
this, std::move(name));
}

ThreadPoolListHook::~ThreadPoolListHook() {
Expand Down

0 comments on commit ab576d6

Please sign in to comment.