diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/boost/libs/thread/test/test_9079_a.cpp | |
parent | Initial commit. (diff) | |
download | ceph-upstream.tar.xz ceph-upstream.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/thread/test/test_9079_a.cpp')
-rw-r--r-- | src/boost/libs/thread/test/test_9079_a.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/boost/libs/thread/test/test_9079_a.cpp b/src/boost/libs/thread/test/test_9079_a.cpp new file mode 100644 index 000000000..3e8ca03fd --- /dev/null +++ b/src/boost/libs/thread/test/test_9079_a.cpp @@ -0,0 +1,57 @@ +// Copyright (C) 2013 Vicente Botet +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// A + +//#include <boost/log/trivial.hpp> +#include <boost/chrono.hpp> +#include <boost/thread.hpp> +#include <boost/thread/condition_variable.hpp> + +//#if !defined(BOOST_NO_CXX11_ALIGNAS) +//#error +//# define BOOST_ALIGNMENT2(x) alignas(x) +//#elif defined(_MSC_VER) +//#error +//# define BOOST_ALIGNMENT2(x) __declspec(align(x)) +//#elif defined(__GNUC__) +//#error +//# define BOOST_ALIGNMENT(x) __attribute__ ((__aligned__(x))) +//#else +//#error +//# define BOOST_NO_ALIGNMENT2 +//# define BOOST_ALIGNMENT2(x) +//#endif + +typedef boost::chrono::high_resolution_clock Clock; +typedef Clock::time_point TimePoint; + +inline TimePoint real_time_now() +{ + return Clock::now(); +} + +int main() +{ + using namespace boost::chrono; + + boost::condition_variable m_task_spawn_condition; + + boost::mutex main_thread_mutex; + boost::unique_lock < boost::mutex > main_thread_lock(main_thread_mutex); + + //BOOST_LOG_TRIVIAL(info) << "[TaskScheduler::run_and_wait] Scheduling loop - BEGIN"; + + //for (;;) + { + static const milliseconds TIME_BACK = milliseconds(1); + m_task_spawn_condition.wait_until( + main_thread_lock, + real_time_now() - TIME_BACK); // wait forever + m_task_spawn_condition.wait_for( main_thread_lock, - TIME_BACK ); // same problem + //BOOST_LOG_TRIVIAL(trace) << "TICK"; + } + +} |