X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2Ftest%2FSynchronizedTestLib-inl.h;h=4a32f7a0d2525220663fffef826373b043d9e32d;hb=d6a27b28486331975bb538ddce4213301d913a1f;hp=faf60f7cb93176197f2b3f9b739d152dcd6c9346;hpb=382372728d0f77c8d430577ea4cf77b53a56a4de;p=folly.git diff --git a/folly/test/SynchronizedTestLib-inl.h b/folly/test/SynchronizedTestLib-inl.h index faf60f7c..4a32f7a0 100644 --- a/folly/test/SynchronizedTestLib-inl.h +++ b/folly/test/SynchronizedTestLib-inl.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Facebook, Inc. + * Copyright 2017 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,11 +16,10 @@ #pragma once -#include - -#include #include #include +#include +#include #include #include #include @@ -468,17 +467,10 @@ void testDeprecated() { EXPECT_EQ(1001, obj.size()); EXPECT_EQ(10, obj.back()); EXPECT_EQ(1000, obj2->size()); - - UNSYNCHRONIZED(obj) { - EXPECT_EQ(1001, obj->size()); - } } SYNCHRONIZED_CONST (obj) { EXPECT_EQ(1001, obj.size()); - UNSYNCHRONIZED(obj) { - EXPECT_EQ(1001, obj->size()); - } } SYNCHRONIZED (lockedObj, *&obj) { @@ -506,7 +498,7 @@ template void testConcurrency() { // Test lock() for (size_t n = 0; n < itersPerThread; ++n) { v.contextualLock()->push_back((itersPerThread * threadIdx) + n); - sched_yield(); + std::this_thread::yield(); } }; runParallel(numThreads, pushNumbers); @@ -771,7 +763,7 @@ template void testTimedSynchronized() { v->push_back(2 * threadIdx); // Aaand test the TIMED_SYNCHRONIZED macro - for (;;) + for (;;) { TIMED_SYNCHRONIZED(5, lv, v) { if (lv) { // Sleep for a random time to ensure we trigger timeouts @@ -784,6 +776,7 @@ template void testTimedSynchronized() { ++(*numTimeouts.contextualLock()); } + } }; static const size_t numThreads = 100; @@ -881,10 +874,8 @@ struct NotCopiableNotMovable { }; template void testInPlaceConstruction() { - // This won't compile without construct_in_place - folly::Synchronized a( - folly::construct_in_place, 5, "a" - ); -} -} + // This won't compile without in_place + folly::Synchronized a(folly::in_place, 5, "a"); } +} // namespace sync_tests +} // namespace folly