Commit c47ff43b authored by Orvid King's avatar Orvid King Committed by Facebook Github Bot

Fix MSVC builds

Summary: The only fix in this diff to an error currently being seen by the contbuilds is the change to concurrent hash map. The rest would have been seen when building the slow tests is enabled.

Reviewed By: yfeldblum

Differential Revision: D14898822

fbshipit-source-id: b28cd697496bb97b0e35b189a9bb31b666da3b17
parent 6607a501
...@@ -506,7 +506,8 @@ if (BUILD_TESTS) ...@@ -506,7 +506,8 @@ if (BUILD_TESTS)
TEST atomic_shared_ptr_test SOURCES AtomicSharedPtrTest.cpp TEST atomic_shared_ptr_test SOURCES AtomicSharedPtrTest.cpp
TEST cache_locality_test SOURCES CacheLocalityTest.cpp TEST cache_locality_test SOURCES CacheLocalityTest.cpp
TEST core_cached_shared_ptr_test SOURCES CoreCachedSharedPtrTest.cpp TEST core_cached_shared_ptr_test SOURCES CoreCachedSharedPtrTest.cpp
TEST concurrent_hash_map_test SOURCES ConcurrentHashMapTest.cpp TEST concurrent_hash_map_test WINDOWS_DISABLED
SOURCES ConcurrentHashMapTest.cpp
TEST dynamic_bounded_queue_test WINDOWS_DISABLED TEST dynamic_bounded_queue_test WINDOWS_DISABLED
SOURCES DynamicBoundedQueueTest.cpp SOURCES DynamicBoundedQueueTest.cpp
TEST priority_unbounded_queue_set_test TEST priority_unbounded_queue_set_test
......
...@@ -790,13 +790,16 @@ TYPED_TEST_P(ConcurrentHashMapTest, ForEachLoop) { ...@@ -790,13 +790,16 @@ TYPED_TEST_P(ConcurrentHashMapTest, ForEachLoop) {
EXPECT_EQ(iters, 1); EXPECT_EQ(iters, 1);
} }
template <typename T>
struct FooBase {
typename T::ConstIterator it;
explicit FooBase(typename T::ConstIterator&& it_) : it(std::move(it_)) {}
FooBase(FooBase&&) = default;
FooBase& operator=(FooBase&&) = default;
};
TYPED_TEST_P(ConcurrentHashMapTest, IteratorMove) { TYPED_TEST_P(ConcurrentHashMapTest, IteratorMove) {
struct Foo { using Foo = FooBase<CHM<int, int>>;
CHM<int, int>::ConstIterator it;
explicit Foo(CHM<int, int>::ConstIterator&& it_) : it(std::move(it_)) {}
Foo(Foo&&) = default;
Foo& operator=(Foo&&) = default;
};
CHM<int, int> map; CHM<int, int> map;
int k = 111; int k = 111;
int v = 999999; int v = 999999;
......
...@@ -319,7 +319,7 @@ void runSimple() { ...@@ -319,7 +319,7 @@ void runSimple() {
EXPECT_TRUE(h8.empty()); EXPECT_TRUE(h8.empty());
EXPECT_EQ(h9.size(), 2); EXPECT_EQ(h9.size(), 2);
auto expectH8 = [&](T& ref) { EXPECT_EQ(&ref, &h8); }; auto expectH8 = [&h8](T& ref) { EXPECT_EQ(&ref, &h8); };
expectH8((h8 = h2)); expectH8((h8 = h2));
expectH8((h8 = std::move(h2))); expectH8((h8 = std::move(h2)));
expectH8((h8 = {})); expectH8((h8 = {}));
......
...@@ -305,7 +305,7 @@ void runSimple() { ...@@ -305,7 +305,7 @@ void runSimple() {
EXPECT_TRUE(h8.empty()); EXPECT_TRUE(h8.empty());
EXPECT_EQ(h9.size(), 2); EXPECT_EQ(h9.size(), 2);
auto expectH8 = [&](T& ref) { EXPECT_EQ(&ref, &h8); }; auto expectH8 = [&h8](T& ref) { EXPECT_EQ(&ref, &h8); };
expectH8((h8 = h2)); expectH8((h8 = h2));
expectH8((h8 = std::move(h2))); expectH8((h8 = std::move(h2)));
expectH8((h8 = {})); expectH8((h8 = {}));
......
...@@ -1639,7 +1639,7 @@ TEST(FiberManager, semaphore) { ...@@ -1639,7 +1639,7 @@ TEST(FiberManager, semaphore) {
template <typename ExecutorT> template <typename ExecutorT>
void singleBatchDispatch(ExecutorT& executor, int batchSize, int index) { void singleBatchDispatch(ExecutorT& executor, int batchSize, int index) {
thread_local BatchDispatcher<int, std::string, ExecutorT> batchDispatcher( thread_local BatchDispatcher<int, std::string, ExecutorT> batchDispatcher(
executor, [=](std::vector<int>&& batch) { executor, [batchSize](std::vector<int>&& batch) {
EXPECT_EQ(batchSize, batch.size()); EXPECT_EQ(batchSize, batch.size());
std::vector<std::string> results; std::vector<std::string> results;
for (auto& it : batch) { for (auto& it : batch) {
...@@ -1687,20 +1687,22 @@ folly::Future<std::vector<std::string>> doubleBatchInnerDispatch( ...@@ -1687,20 +1687,22 @@ folly::Future<std::vector<std::string>> doubleBatchInnerDispatch(
std::vector<int>, std::vector<int>,
std::vector<std::string>, std::vector<std::string>,
ExecutorT> ExecutorT>
batchDispatcher(executor, [=](std::vector<std::vector<int>>&& batch) { batchDispatcher(
std::vector<std::vector<std::string>> results; executor,
int numberOfElements = 0; [totalNumberOfElements](std::vector<std::vector<int>>&& batch) {
for (auto& unit : batch) { std::vector<std::vector<std::string>> results;
numberOfElements += unit.size(); int numberOfElements = 0;
std::vector<std::string> result; for (auto& unit : batch) {
for (auto& element : unit) { numberOfElements += unit.size();
result.push_back(folly::to<std::string>(element)); std::vector<std::string> result;
} for (auto& element : unit) {
results.push_back(std::move(result)); result.push_back(folly::to<std::string>(element));
} }
EXPECT_EQ(totalNumberOfElements, numberOfElements); results.push_back(std::move(result));
return results; }
}); EXPECT_EQ(totalNumberOfElements, numberOfElements);
return results;
});
return batchDispatcher.add(std::move(input)); return batchDispatcher.add(std::move(input));
} }
......
...@@ -322,7 +322,7 @@ void simpleStressTest(Duration duration, int numThreads) { ...@@ -322,7 +322,7 @@ void simpleStressTest(Duration duration, int numThreads) {
auto&& stop = std::atomic<bool>{true}; auto&& stop = std::atomic<bool>{true};
for (auto i = 0; i < numThreads; ++i) { for (auto i = 0; i < numThreads; ++i) {
threads.emplace_back([&] { threads.emplace_back([&mutex, &data, &stop] {
while (!stop.load(std::memory_order_relaxed)) { while (!stop.load(std::memory_order_relaxed)) {
auto lck = std::unique_lock<Mutex>{mutex}; auto lck = std::unique_lock<Mutex>{mutex};
EXPECT_EQ(data.fetch_add(1, std::memory_order_relaxed), 0); EXPECT_EQ(data.fetch_add(1, std::memory_order_relaxed), 0);
......
...@@ -84,7 +84,7 @@ void unique_ptr_test(Allocator& allocator) { ...@@ -84,7 +84,7 @@ void unique_ptr_test(Allocator& allocator) {
auto p = folly::allocate_unique<Foo>(allocator, counter); auto p = folly::allocate_unique<Foo>(allocator, counter);
EXPECT_EQ(counter.count(), 2); EXPECT_EQ(counter.count(), 2);
[&](ptr_type g) { [&counter](ptr_type g) {
EXPECT_EQ(counter.count(), 2); EXPECT_EQ(counter.count(), 2);
g.reset(); g.reset();
EXPECT_EQ(counter.count(), 1); EXPECT_EQ(counter.count(), 1);
...@@ -137,7 +137,7 @@ void shared_ptr_test(Allocator& allocator) { ...@@ -137,7 +137,7 @@ void shared_ptr_test(Allocator& allocator) {
EXPECT_EQ(counter.count(), 1); EXPECT_EQ(counter.count(), 1);
EXPECT_EQ(p.use_count(), 2); EXPECT_EQ(p.use_count(), 2);
[&](ptr_type g) { [&counter, &p](ptr_type g) {
EXPECT_EQ(counter.count(), 1); EXPECT_EQ(counter.count(), 1);
EXPECT_EQ(p.use_count(), 3); EXPECT_EQ(p.use_count(), 3);
EXPECT_EQ(g.use_count(), 3); EXPECT_EQ(g.use_count(), 3);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment