sapling/eden/fs/testharness/InodeUnloader.h
Chad Austin 5070d76451 fix TreeInode::unloadChildrenNow so it unloads trees
Summary:
unloadChildrenNow would only unload files or trees at the leaf. Apply
the fixes from D8302998 to unloadChildrenNow, which is only called
during takeover.

Reviewed By: strager

Differential Revision: D9774970

fbshipit-source-id: c2f4d1e6b838cc3b9e99eb8786114e643128a519
2018-09-12 14:37:24 -07:00

38 lines
971 B
C++

/*
* Copyright (c) 2018-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.
*
*/
#pragma once
#include <gtest/gtest.h>
#include "eden/fs/inodes/TreeInode.h"
namespace facebook {
namespace eden {
struct ConditionalUnloader {
static size_t unload(TreeInode& unloadFrom) {
timespec endOfTime;
endOfTime.tv_sec = std::numeric_limits<time_t>::max();
endOfTime.tv_nsec = 999999999;
return unloadFrom.unloadChildrenLastAccessedBefore(endOfTime);
}
};
struct UnconditionalUnloader {
static size_t unload(TreeInode& unloadFrom) {
return unloadFrom.unloadChildrenNow();
}
};
using InodeUnloaderTypes =
::testing::Types<ConditionalUnloader, UnconditionalUnloader>;
} // namespace eden
} // namespace facebook