sapling/eden/fs/utils/UnboundedQueueExecutor.cpp
Chad Austin bfc189cc92 Use a deterministic executor in TestMount
Summary:
As a prerequisite to running inode unloading code in a background
queue, use a deterministic executor in TestMount to make sequencing in
unit tests reliable.

Reviewed By: simpkins

Differential Revision: D9323878

fbshipit-source-id: 0b85632c1637a8cf83d6f238675e5b6bbb6923c7
2018-08-21 12:23:00 -07:00

35 lines
1.2 KiB
C++

/*
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#include "eden/fs/utils/UnboundedQueueExecutor.h"
#include <folly/executors/CPUThreadPoolExecutor.h>
#include <folly/executors/ManualExecutor.h>
#include <folly/executors/task_queue/UnboundedBlockingQueue.h>
#include <folly/executors/thread_factory/NamedThreadFactory.h>
namespace facebook {
namespace eden {
UnboundedQueueExecutor::UnboundedQueueExecutor(
size_t threadCount,
folly::StringPiece threadNamePrefix)
: executor_{std::make_unique<folly::CPUThreadPoolExecutor>(
threadCount,
std::make_unique<folly::UnboundedBlockingQueue<
folly::CPUThreadPoolExecutor::CPUTask>>(),
std::make_unique<folly::NamedThreadFactory>(threadNamePrefix))} {}
UnboundedQueueExecutor::UnboundedQueueExecutor(
std::shared_ptr<folly::ManualExecutor> executor)
: executor_{std::move(executor)} {}
} // namespace eden
} // namespace facebook