Commit 31005a98 authored by Peter Griess's avatar Peter Griess Committed by Sara Golemon

Check for std::this_thread::sleep_for.

Summary:
- Some installations of libstdc++ don't have this defined. This happens
if they were built without --enable-libstdcxx-time. Detect this and
avoid tests that rely on this behavior.

Test Plan:
- fbconfig -r folly && fbmake runtests
- ./configure && make check on Ubuntu/FC/Mac

Reviewed By: meyering@fb.com

FB internal diff: D1002963
parent 77cc480d
...@@ -78,6 +78,15 @@ AC_COMPILE_IFELSE( ...@@ -78,6 +78,15 @@ AC_COMPILE_IFELSE(
AC_DEFINE([OVERRIDE], [], AC_DEFINE([OVERRIDE], [],
[Define to "override" if the compiler supports C++11 "override"])] [Define to "override" if the compiler supports C++11 "override"])]
) )
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE[
#include <thread>
#include <chrono>
void func() { std::this_thread::sleep_for(std::chrono::seconds(1)); }]],
[AC_DEFINE([HAVE_STD__THIS_THREAD__SLEEP_FOR], [1],
[Define to 1 if std::this_thread::sleep_for() is defined.])])
AC_COMPILE_IFELSE( AC_COMPILE_IFELSE(
[AC_LANG_SOURCE[ [AC_LANG_SOURCE[
#include <type_traits> #include <type_traits>
......
...@@ -346,6 +346,7 @@ class FillObject { ...@@ -346,6 +346,7 @@ class FillObject {
} // namespace } // namespace
#if FOLLY_HAVE_STD__THIS_THREAD__SLEEP_FOR
TEST(ThreadLocal, Stress) { TEST(ThreadLocal, Stress) {
constexpr size_t numFillObjects = 250; constexpr size_t numFillObjects = 250;
std::array<ThreadLocalPtr<FillObject>, numFillObjects> objects; std::array<ThreadLocalPtr<FillObject>, numFillObjects> objects;
...@@ -376,6 +377,7 @@ TEST(ThreadLocal, Stress) { ...@@ -376,6 +377,7 @@ TEST(ThreadLocal, Stress) {
EXPECT_EQ(numFillObjects * numThreads * numReps, gDestroyed); EXPECT_EQ(numFillObjects * numThreads * numReps, gDestroyed);
} }
#endif
// Yes, threads and fork don't mix // Yes, threads and fork don't mix
// (http://cppwisdom.quora.com/Why-threads-and-fork-dont-mix) but if you're // (http://cppwisdom.quora.com/Why-threads-and-fork-dont-mix) but if you're
......
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