mirror of
https://github.com/boostorg/thread.git
synced 2026-01-25 18:52:16 +00:00
# By Vicente J. Botet Escriba (274) and others # Via Vicente J. Botet Escriba (42) and others * 'master' of https://github.com/boostorg/thread: (318 commits) Added missing include. cleanup future.hpp. Updated CI dashboard with latest tests. Looks like timeconv.inl may be completely unnecessary, so remove. Could find no code anywhere in Boost which uses to_time(), to_timespec_duration(), to_duration() nor to_microduration(), so removed the code. Fixed MSVC static analyser warning about writing off the end of an array. Stop LNK4221 link warning with link=static. Suppressed some unimportant warnings so the CI doesn't flag them. Added static analysers to CI dashboard. Added winphone8 build test. Fix failure to build on Android. redo Added overall build and test status Added test matrix to Readme.md so a summary appears on github fix some typos. ensure that the exceptions throw by a task submitted by a serial executor are transfered to it, and so the serial_executor doesn't block forever. No comment after preprocessor continuation for msvc-12.0 Added ! defined __clang__ when tested defined __GNUC__. Added BOOST_THREAD_PROVIDES_INVOKE constraing for invoker. thread: physical_concurrency - return 0 instead of hardware_concurrency on failure ... Conflicts: test/test_2741.cpp
88 lines
2.2 KiB
C++
88 lines
2.2 KiB
C++
// Copyright (C) 2008 Vicente J. Botet Escriba
|
|
// 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)
|
|
|
|
#define BOOST_THREAD_VERSION 2
|
|
#define BOOST_TEST_MODULE Boost.Threads: thread attributes test suite
|
|
#include <boost/thread/detail/config.hpp>
|
|
|
|
#include <boost/thread/thread_only.hpp>
|
|
#include <boost/thread/xtime.hpp>
|
|
#include <boost/bind.hpp>
|
|
#include <boost/ref.hpp>
|
|
#include <boost/utility.hpp>
|
|
|
|
#include <iostream>
|
|
#include <boost/test/unit_test.hpp>
|
|
|
|
#define DEFAULT_EXECUTION_MONITOR_TYPE execution_monitor::use_sleep_only
|
|
#include "./util.inl"
|
|
|
|
int test_value;
|
|
#ifdef PTHREAD_STACK_MIN
|
|
#define MY_PTHREAD_STACK PTHREAD_STACK_MIN
|
|
#else
|
|
#define MY_PTHREAD_STACK 4*0x4000
|
|
#endif
|
|
void simple_thread()
|
|
{
|
|
test_value = 999;
|
|
}
|
|
|
|
BOOST_AUTO_TEST_CASE(test_native_handle)
|
|
{
|
|
|
|
boost::thread_attributes attrs;
|
|
|
|
boost::thread_attributes::native_handle_type* h = attrs.native_handle();
|
|
#if defined(BOOST_THREAD_PLATFORM_WIN32)
|
|
// ... window version
|
|
#elif defined(BOOST_THREAD_PLATFORM_PTHREAD)
|
|
|
|
int k = pthread_attr_setstacksize(h, MY_PTHREAD_STACK);
|
|
std::cout << k << std::endl;
|
|
BOOST_CHECK(!pthread_attr_setstacksize(h, MY_PTHREAD_STACK));
|
|
std::size_t res;
|
|
BOOST_CHECK(!pthread_attr_getstacksize(h, &res));
|
|
BOOST_CHECK(res >= (MY_PTHREAD_STACK));
|
|
#else
|
|
#error "Boost thread unavailable on this platform"
|
|
#endif
|
|
|
|
}
|
|
|
|
BOOST_AUTO_TEST_CASE(test_stack_size)
|
|
{
|
|
boost::thread_attributes attrs;
|
|
|
|
attrs.set_stack_size(0x4000);
|
|
BOOST_CHECK(attrs.get_stack_size() >= 0x4000);
|
|
|
|
}
|
|
|
|
void do_test_creation_with_attrs()
|
|
{
|
|
test_value = 0;
|
|
boost::thread_attributes attrs;
|
|
attrs.set_stack_size(0x4000);
|
|
boost::thread thrd(attrs, &simple_thread);
|
|
thrd.join();
|
|
BOOST_CHECK_EQUAL(test_value, 999);
|
|
}
|
|
|
|
BOOST_AUTO_TEST_CASE(test_creation_with_attrs)
|
|
{
|
|
timed_test(&do_test_creation_with_attrs, 1);
|
|
}
|
|
|
|
boost::unit_test_framework::test_suite* init_unit_test_suite(int, char*[])
|
|
{
|
|
boost::unit_test_framework::test_suite* test = BOOST_TEST_SUITE("Boost.Threads: thread attributes test suite");
|
|
|
|
test->add(BOOST_TEST_CASE(test_native_handle));
|
|
test->add(BOOST_TEST_CASE(test_stack_size));
|
|
test->add(BOOST_TEST_CASE(test_creation_with_attrs));
|
|
|
|
return test;
|
|
}
|