early-access version 3088

This commit is contained in:
pineappleEA
2022-11-05 15:35:56 +01:00
parent 4e4fc25ce3
commit b601909c6d
35519 changed files with 5996896 additions and 860 deletions

View File

@@ -0,0 +1,98 @@
// (C) Copyright 2008-10 Anthony Williams
// (C) Copyright 2011-2015 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)
#ifndef BOOST_THREAD_FUTURES_FUTURE_ERROR_HPP
#define BOOST_THREAD_FUTURES_FUTURE_ERROR_HPP
#include <boost/thread/detail/config.hpp>
#include <boost/thread/futures/future_error_code.hpp>
#include <boost/system/error_code.hpp>
#include <stdexcept>
namespace boost
{
class BOOST_SYMBOL_VISIBLE future_error
: public std::logic_error
{
system::error_code ec_;
public:
future_error(system::error_code ec)
: logic_error(ec.message()),
ec_(ec)
{
}
const system::error_code& code() const BOOST_NOEXCEPT
{
return ec_;
}
};
class BOOST_SYMBOL_VISIBLE future_uninitialized:
public future_error
{
public:
future_uninitialized() :
future_error(system::make_error_code(future_errc::no_state))
{}
};
class BOOST_SYMBOL_VISIBLE broken_promise:
public future_error
{
public:
broken_promise():
future_error(system::make_error_code(future_errc::broken_promise))
{}
};
class BOOST_SYMBOL_VISIBLE future_already_retrieved:
public future_error
{
public:
future_already_retrieved():
future_error(system::make_error_code(future_errc::future_already_retrieved))
{}
};
class BOOST_SYMBOL_VISIBLE promise_already_satisfied:
public future_error
{
public:
promise_already_satisfied():
future_error(system::make_error_code(future_errc::promise_already_satisfied))
{}
};
class BOOST_SYMBOL_VISIBLE task_already_started:
public future_error
{
public:
task_already_started():
future_error(system::make_error_code(future_errc::promise_already_satisfied))
{}
};
class BOOST_SYMBOL_VISIBLE task_moved:
public future_error
{
public:
task_moved():
future_error(system::make_error_code(future_errc::no_state))
{}
};
class promise_moved:
public future_error
{
public:
promise_moved():
future_error(system::make_error_code(future_errc::no_state))
{}
};
}
#endif // header

View File

@@ -0,0 +1,61 @@
// (C) Copyright 2008-10 Anthony Williams
// (C) Copyright 2011-2012,2015 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)
#ifndef BOOST_THREAD_FUTURES_FUTURE_ERROR_CODE_HPP
#define BOOST_THREAD_FUTURES_FUTURE_ERROR_CODE_HPP
#include <boost/thread/detail/config.hpp>
#include <boost/core/scoped_enum.hpp>
#include <boost/system/error_code.hpp>
#include <boost/type_traits/integral_constant.hpp>
namespace boost
{
//enum class future_errc
BOOST_SCOPED_ENUM_DECLARE_BEGIN(future_errc)
{
broken_promise = 1,
future_already_retrieved,
promise_already_satisfied,
no_state
}
BOOST_SCOPED_ENUM_DECLARE_END(future_errc)
namespace system
{
template <>
struct BOOST_SYMBOL_VISIBLE is_error_code_enum< ::boost::future_errc> : public true_type {};
#ifdef BOOST_NO_CXX11_SCOPED_ENUMS
template <>
struct BOOST_SYMBOL_VISIBLE is_error_code_enum< ::boost::future_errc::enum_type> : public true_type { };
#endif
} // system
BOOST_THREAD_DECL
const system::error_category& future_category() BOOST_NOEXCEPT;
namespace system
{
inline
error_code
make_error_code(future_errc e) BOOST_NOEXCEPT
{
return error_code(underlying_cast<int>(e), boost::future_category());
}
inline
error_condition
make_error_condition(future_errc e) BOOST_NOEXCEPT
{
return error_condition(underlying_cast<int>(e), boost::future_category());
}
} // system
} // boost
#endif // header

View File

@@ -0,0 +1,30 @@
// (C) Copyright 2008-10 Anthony Williams
// (C) Copyright 2011-2015 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)
#ifndef BOOST_THREAD_FUTURES_FUTURE_STATUS_HPP
#define BOOST_THREAD_FUTURES_FUTURE_STATUS_HPP
#include <boost/thread/detail/config.hpp>
#include <boost/core/scoped_enum.hpp>
namespace boost
{
//enum class future_status
BOOST_SCOPED_ENUM_DECLARE_BEGIN(future_status)
{
ready,
timeout,
deferred
}
BOOST_SCOPED_ENUM_DECLARE_END(future_status)
namespace future_state
{
enum state { uninitialized, waiting, ready, moved, deferred };
}
}
#endif // header

View File

@@ -0,0 +1,21 @@
// (C) Copyright 2008-10 Anthony Williams
// (C) Copyright 2011-2015 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)
#ifndef BOOST_THREAD_FUTURES_IS_FUTURE_TYPE_HPP
#define BOOST_THREAD_FUTURES_IS_FUTURE_TYPE_HPP
#include <boost/type_traits/integral_constant.hpp>
namespace boost
{
template<typename T>
struct is_future_type : false_type
{
};
}
#endif // header

View File

@@ -0,0 +1,32 @@
// (C) Copyright 2008-10 Anthony Williams
// (C) Copyright 2011-2015 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)
#ifndef BOOST_THREAD_FUTURES_LAUNCH_HPP
#define BOOST_THREAD_FUTURES_LAUNCH_HPP
#include <boost/thread/detail/config.hpp>
#include <boost/core/scoped_enum.hpp>
namespace boost
{
//enum class launch
BOOST_SCOPED_ENUM_DECLARE_BEGIN(launch)
{
none = 0,
async = 1,
deferred = 2,
#ifdef BOOST_THREAD_PROVIDES_EXECUTORS
executor = 4,
#endif
inherit = 8,
sync = 16,
any = async | deferred
}
BOOST_SCOPED_ENUM_DECLARE_END(launch)
}
#endif // header

View File

@@ -0,0 +1,74 @@
// (C) Copyright 2008-10 Anthony Williams
// (C) Copyright 2011-2015 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)
#ifndef BOOST_THREAD_FUTURES_WAIT_FOR_ALL_HPP
#define BOOST_THREAD_FUTURES_WAIT_FOR_ALL_HPP
#include <boost/thread/detail/config.hpp>
#include <boost/thread/futures/is_future_type.hpp>
#include <boost/core/enable_if.hpp>
namespace boost
{
template<typename Iterator>
typename boost::disable_if<is_future_type<Iterator>,void>::type wait_for_all(Iterator begin,Iterator end)
{
for(Iterator current=begin;current!=end;++current)
{
current->wait();
}
}
#ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES
template<typename F1,typename F2>
typename boost::enable_if<is_future_type<F1>,void>::type wait_for_all(F1& f1,F2& f2)
{
f1.wait();
f2.wait();
}
template<typename F1,typename F2,typename F3>
void wait_for_all(F1& f1,F2& f2,F3& f3)
{
f1.wait();
f2.wait();
f3.wait();
}
template<typename F1,typename F2,typename F3,typename F4>
void wait_for_all(F1& f1,F2& f2,F3& f3,F4& f4)
{
f1.wait();
f2.wait();
f3.wait();
f4.wait();
}
template<typename F1,typename F2,typename F3,typename F4,typename F5>
void wait_for_all(F1& f1,F2& f2,F3& f3,F4& f4,F5& f5)
{
f1.wait();
f2.wait();
f3.wait();
f4.wait();
f5.wait();
}
#else
template<typename F1, typename... Fs>
typename boost::enable_if<is_future_type<F1>,void>::type wait_for_all(F1& f1, Fs&... fs)
{
bool dummy[] = { (f1.wait(), true), (fs.wait(), true)... };
// prevent unused parameter warning
(void) dummy;
}
#endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)}
}
#endif // header

View File

@@ -0,0 +1,162 @@
// (C) Copyright 2008-10 Anthony Williams
// (C) Copyright 2011-2015 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)
#ifndef BOOST_THREAD_FUTURES_WAIT_FOR_ANY_HPP
#define BOOST_THREAD_FUTURES_WAIT_FOR_ANY_HPP
#include <boost/thread/detail/config.hpp>
#include <boost/thread/detail/move.hpp>
#include <boost/thread/futures/is_future_type.hpp>
#include <boost/thread/lock_algorithms.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition_variable.hpp>
#include <boost/core/enable_if.hpp>
#include <boost/next_prior.hpp>
#include <boost/scoped_array.hpp>
#include <iterator>
#include <vector>
namespace boost
{
namespace detail
{
template <class Future>
class waiter_for_any_in_seq
{
struct registered_waiter;
typedef std::vector<int>::size_type count_type;
struct registered_waiter
{
typedef Future future_type;
future_type* future_;
typedef typename Future::notify_when_ready_handle notify_when_ready_handle;
notify_when_ready_handle handle;
count_type index;
registered_waiter(future_type & a_future,
notify_when_ready_handle handle_, count_type index_) :
future_(&a_future), handle(handle_), index(index_)
{
}
};
struct all_futures_lock
{
#ifdef _MANAGED
typedef std::ptrdiff_t count_type_portable;
#else
typedef count_type count_type_portable;
#endif
count_type_portable count;
boost::scoped_array<boost::unique_lock<boost::mutex> > locks;
all_futures_lock(std::vector<registered_waiter>& waiters) :
count(waiters.size()), locks(new boost::unique_lock<boost::mutex>[count])
{
for (count_type_portable i = 0; i < count; ++i)
{
locks[i] = BOOST_THREAD_MAKE_RV_REF(boost::unique_lock<boost::mutex>(waiters[i].future_->mutex()));
}
}
void lock()
{
boost::lock(locks.get(), locks.get() + count);
}
void unlock()
{
for (count_type_portable i = 0; i < count; ++i)
{
locks[i].unlock();
}
}
};
boost::condition_variable_any cv;
std::vector<registered_waiter> waiters_;
count_type future_count;
public:
waiter_for_any_in_seq() :
future_count(0)
{
}
template <typename F>
void add(F& f)
{
if (f.valid())
{
registered_waiter waiter(f, f.notify_when_ready(cv), future_count);
try
{
waiters_.push_back(waiter);
}
catch (...)
{
f.future_->unnotify_when_ready(waiter.handle);
throw;
}
++future_count;
}
}
#ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES
template <typename F1, typename ... Fs>
void add(F1& f1, Fs&... fs)
{
add(f1);
add(fs...);
}
#endif
count_type wait()
{
all_futures_lock lk(waiters_);
for (;;)
{
for (count_type i = 0; i < waiters_.size(); ++i)
{
if (waiters_[i].future_->is_ready(lk.locks[i]))
{
return waiters_[i].index;
}
}
cv.wait(lk);
}
}
~waiter_for_any_in_seq()
{
for (count_type i = 0; i < waiters_.size(); ++i)
{
waiters_[i].future_->unnotify_when_ready(waiters_[i].handle);
}
}
};
}
template <typename Iterator>
typename boost::disable_if<is_future_type<Iterator> , Iterator>::type wait_for_any(Iterator begin, Iterator end)
{
if (begin == end) return end;
detail::waiter_for_any_in_seq<typename std::iterator_traits<Iterator>::value_type> waiter;
for (Iterator current = begin; current != end; ++current)
{
waiter.add(*current);
}
return boost::next(begin, waiter.wait());
}
}
#endif // header