diff options
author | dmauro <dmauro@google.com> | 2021-10-25 17:40:39 (GMT) |
---|---|---|
committer | CJ Johnson <johnsoncj@google.com> | 2021-11-03 17:45:40 (GMT) |
commit | 489ef888d942ecd40063b0e074b2901a2c1754bb (patch) | |
tree | b9942c8fba7363ef1050132bb00b98e95736c94c /googletest/test | |
parent | f503588aeee4629e5673f2d88ddec01c9ed4bd6b (diff) | |
download | googletest-489ef888d942ecd40063b0e074b2901a2c1754bb.zip googletest-489ef888d942ecd40063b0e074b2901a2c1754bb.tar.gz googletest-489ef888d942ecd40063b0e074b2901a2c1754bb.tar.bz2 |
Googletest export
Remove GoogleTest's SleepMilliseconds function.
It is only used in tests and a portable implementation is available.
PiperOrigin-RevId: 405437102
Diffstat (limited to 'googletest/test')
-rw-r--r-- | googletest/test/googletest-port-test.cc | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/googletest/test/googletest-port-test.cc b/googletest/test/googletest-port-test.cc index 16d30c4..b14e1f7 100644 --- a/googletest/test/googletest-port-test.cc +++ b/googletest/test/googletest-port-test.cc @@ -36,8 +36,10 @@ # include <time.h> #endif // GTEST_OS_MAC +#include <chrono> // NOLINT #include <list> #include <memory> +#include <thread> // NOLINT #include <utility> // For std::pair and std::make_pair. #include <vector> @@ -333,7 +335,7 @@ TEST(GetThreadCountTest, ReturnsCorrectValue) { break; } - SleepMilliseconds(100); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } // Retry if an arbitrary other thread was created or destroyed. @@ -1050,7 +1052,7 @@ class AtomicCounterWithMutex { int temp = value_; { // We need to put up a memory barrier to prevent reads and writes to - // value_ rearranged with the call to SleepMilliseconds when observed + // value_ rearranged with the call to sleep_for when observed // from other threads. #if GTEST_HAS_PTHREAD // On POSIX, locking a mutex puts up a memory barrier. We cannot use @@ -1061,7 +1063,8 @@ class AtomicCounterWithMutex { pthread_mutex_init(&memory_barrier_mutex, nullptr)); GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_lock(&memory_barrier_mutex)); - SleepMilliseconds(static_cast<int>(random_.Generate(30))); + std::this_thread::sleep_for( + std::chrono::milliseconds(random_.Generate(30))); GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_unlock(&memory_barrier_mutex)); GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_destroy(&memory_barrier_mutex)); @@ -1069,7 +1072,8 @@ class AtomicCounterWithMutex { // On Windows, performing an interlocked access puts up a memory barrier. volatile LONG dummy = 0; ::InterlockedIncrement(&dummy); - SleepMilliseconds(static_cast<int>(random_.Generate(30))); + std::this_thread::sleep_for( + std::chrono::milliseconds(random_.Generate(30))); ::InterlockedIncrement(&dummy); #else # error "Memory barrier not implemented on this platform." |