mirror of
https://github.com/facebook/sapling.git
synced 2024-10-05 14:28:17 +03:00
testharness: remove QueuedImmediateExecutor from TestMount
Summary: We can merely change the code to use ImmediateFuture and let the callsite (tests) attach the server executor to it if needed. Reviewed By: genevievehelsel Differential Revision: D50415723 fbshipit-source-id: 5edc144b5e54a2c29afe686a57bd60c370d57292
This commit is contained in:
parent
ef62822cf1
commit
07e29c30a5
@ -31,7 +31,6 @@ cpp_library(
|
||||
"//eden/fs/utils:user_info",
|
||||
"//eden/fs/utils:utils",
|
||||
"//folly:file_util",
|
||||
"//folly/executors:queued_immediate_executor",
|
||||
"//folly/experimental:test_util",
|
||||
"//folly/io:iobuf",
|
||||
"//folly/logging:logging",
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
#include <folly/FileUtil.h>
|
||||
#include <folly/executors/ManualExecutor.h>
|
||||
#include <folly/executors/QueuedImmediateExecutor.h>
|
||||
#include <folly/experimental/TestUtil.h>
|
||||
#include <folly/io/IOBuf.h>
|
||||
#include <folly/logging/xlog.h>
|
||||
@ -54,8 +53,6 @@
|
||||
#include "eden/fs/utils/UnboundedQueueExecutor.h"
|
||||
#include "eden/fs/utils/UserInfo.h"
|
||||
|
||||
using folly::Future;
|
||||
using folly::makeFuture;
|
||||
using folly::Unit;
|
||||
using namespace std::chrono_literals;
|
||||
using namespace std::string_literals;
|
||||
@ -835,12 +832,12 @@ VirtualInode TestMount::getVirtualInode(folly::StringPiece path) const {
|
||||
}
|
||||
|
||||
void TestMount::loadAllInodes() {
|
||||
auto fut = loadAllInodesFuture().via(getServerExecutor().get());
|
||||
auto fut = loadAllInodesFuture().semi().via(getServerExecutor().get());
|
||||
drainServerExecutor();
|
||||
std::move(fut).get(std::chrono::milliseconds(1));
|
||||
}
|
||||
|
||||
Future<Unit> TestMount::loadAllInodesFuture() {
|
||||
ImmediateFuture<Unit> TestMount::loadAllInodesFuture() {
|
||||
return loadAllInodesFuture(edenMount_->getRootInode());
|
||||
}
|
||||
|
||||
@ -848,7 +845,8 @@ void TestMount::loadAllInodes(const TreeInodePtr& treeInode) {
|
||||
loadAllInodesFuture(treeInode).get();
|
||||
}
|
||||
|
||||
Future<Unit> TestMount::loadAllInodesFuture(const TreeInodePtr& treeInode) {
|
||||
ImmediateFuture<Unit> TestMount::loadAllInodesFuture(
|
||||
const TreeInodePtr& treeInode) {
|
||||
// Build a list of child names to load.
|
||||
// (If necessary we could make a more efficient version of this that starts
|
||||
// all the child loads while holding the lock. However, we don't really care
|
||||
@ -862,22 +860,20 @@ Future<Unit> TestMount::loadAllInodesFuture(const TreeInodePtr& treeInode) {
|
||||
}
|
||||
|
||||
// Now start all the loads.
|
||||
std::vector<Future<Unit>> childFutures;
|
||||
std::vector<ImmediateFuture<Unit>> childFutures;
|
||||
for (const auto& name : childNames) {
|
||||
auto childFuture =
|
||||
treeInode->getOrLoadChild(name, ObjectFetchContext::getNullContext())
|
||||
.semi()
|
||||
.via(&folly::QueuedImmediateExecutor::instance())
|
||||
.thenValue([](InodePtr child) {
|
||||
.thenValue([](InodePtr child) -> ImmediateFuture<folly::Unit> {
|
||||
TreeInodePtr childTree = child.asTreePtrOrNull();
|
||||
if (childTree) {
|
||||
return loadAllInodesFuture(childTree);
|
||||
}
|
||||
return makeFuture();
|
||||
return folly::unit;
|
||||
});
|
||||
childFutures.emplace_back(std::move(childFuture));
|
||||
}
|
||||
return folly::collectUnsafe(childFutures).unit();
|
||||
return collectAllSafe(std::move(childFutures)).unit();
|
||||
}
|
||||
|
||||
std::shared_ptr<const Tree> TestMount::getRootTree() const {
|
||||
|
@ -25,8 +25,6 @@
|
||||
#include "eden/fs/utils/PathFuncs.h"
|
||||
|
||||
namespace folly {
|
||||
template <typename T>
|
||||
class Future;
|
||||
struct Unit;
|
||||
class ManualExecutor;
|
||||
|
||||
@ -314,13 +312,13 @@ class TestMount {
|
||||
* Walk the entire tree and load all inode objects.
|
||||
*/
|
||||
void loadAllInodes();
|
||||
FOLLY_NODISCARD folly::Future<folly::Unit> loadAllInodesFuture();
|
||||
FOLLY_NODISCARD ImmediateFuture<folly::Unit> loadAllInodesFuture();
|
||||
|
||||
/**
|
||||
* Load all inodes [recursively] under the specified subdirectory.
|
||||
*/
|
||||
static void loadAllInodes(const TreeInodePtr& treeInode);
|
||||
FOLLY_NODISCARD static folly::Future<folly::Unit> loadAllInodesFuture(
|
||||
FOLLY_NODISCARD static ImmediateFuture<folly::Unit> loadAllInodesFuture(
|
||||
const TreeInodePtr& treeInode);
|
||||
|
||||
/** Convenience method for getting the Tree for the root of the mount. */
|
||||
|
Loading…
Reference in New Issue
Block a user