From 894ab45052b031613e99f83cba2d9f93bea44065 Mon Sep 17 00:00:00 2001 From: Damian Jarek Date: Mon, 27 May 2019 02:06:27 +0200 Subject: [PATCH] Remove experimental/unit_test/thread.hpp The file has been unused in Beast for a few releases. Actions required: - Copy the `thread` class into your project. Signed-off-by: Damian Jarek --- CHANGELOG.md | 1 + .../beast/_experimental/unit_test/thread.hpp | 128 ------------------ 2 files changed, 1 insertion(+), 128 deletions(-) delete mode 100644 include/boost/beast/_experimental/unit_test/thread.hpp diff --git a/CHANGELOG.md b/CHANGELOG.md index 053aa0cc..e5f9afff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ Version 257: * Add b2 features for compile-time options used in testing * Remove redundant dependencies in http/server/fast example +* Remove experimental/unit_test/thread.hpp -------------------------------------------------------------------------------- diff --git a/include/boost/beast/_experimental/unit_test/thread.hpp b/include/boost/beast/_experimental/unit_test/thread.hpp deleted file mode 100644 index ed06cb37..00000000 --- a/include/boost/beast/_experimental/unit_test/thread.hpp +++ /dev/null @@ -1,128 +0,0 @@ -// -// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) -// -// 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) -// -// Official repository: https://github.com/boostorg/beast -// - -#ifndef BOOST_BEAST_UNIT_TEST_THREAD_HPP -#define BOOST_BEAST_UNIT_TEST_THREAD_HPP - -#include -#include -#include -#include - -namespace boost { -namespace beast { -namespace unit_test { - -/** Replacement for std::thread that handles exceptions in unit tests. */ -class thread -{ -private: - suite* s_ = nullptr; - std::thread t_; - -public: - using id = std::thread::id; - using native_handle_type = std::thread::native_handle_type; - - thread() = default; - thread(thread const&) = delete; - thread& operator=(thread const&) = delete; - - thread(thread&& other) - : s_(other.s_) - , t_(std::move(other.t_)) - { - } - - thread& operator=(thread&& other) - { - s_ = other.s_; - t_ = std::move(other.t_); - return *this; - } - - template - explicit - thread(suite& s, F&& f, Args&&... args) - : s_(&s) - { - std::function b = - std::bind(std::forward(f), - std::forward(args)...); - t_ = std::thread(&thread::run, this, - std::move(b)); - } - - bool - joinable() const - { - return t_.joinable(); - } - - std::thread::id - get_id() const - { - return t_.get_id(); - } - - static - unsigned - hardware_concurrency() noexcept - { - return std::thread::hardware_concurrency(); - } - - void - join() - { - t_.join(); - s_->propagate_abort(); - } - - void - detach() - { - t_.detach(); - } - - void - swap(thread& other) - { - std::swap(s_, other.s_); - std::swap(t_, other.t_); - } - -private: - void - run(std::function f) - { - try - { - f(); - } - catch(suite::abort_exception const&) - { - } - catch(std::exception const& e) - { - s_->fail("unhandled exception: " + - std::string(e.what())); - } - catch(...) - { - s_->fail("unhandled exception"); - } - } -}; - -} // unit_test -} // beast -} // boost - -#endif