stabilize build system: depends, installer, boost/bdb fixes, cross targets groundwork
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
// Copyright Oliver Kowalke 2013.
|
||||
// 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_FIBERS_ALGO_ALGORITHM_H
|
||||
#define BOOST_FIBERS_ALGO_ALGORITHM_H
|
||||
|
||||
#include <cstddef>
|
||||
#include <chrono>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include <boost/fiber/properties.hpp>
|
||||
#include <boost/fiber/detail/config.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_PREFIX
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace fibers {
|
||||
|
||||
class context;
|
||||
|
||||
namespace algo {
|
||||
|
||||
struct BOOST_FIBERS_DECL algorithm {
|
||||
virtual ~algorithm() {}
|
||||
|
||||
virtual void awakened( context *) noexcept = 0;
|
||||
|
||||
virtual context * pick_next() noexcept = 0;
|
||||
|
||||
virtual bool has_ready_fibers() const noexcept = 0;
|
||||
|
||||
virtual void suspend_until( std::chrono::steady_clock::time_point const&) noexcept = 0;
|
||||
|
||||
virtual void notify() noexcept = 0;
|
||||
};
|
||||
|
||||
class BOOST_FIBERS_DECL algorithm_with_properties_base : public algorithm {
|
||||
public:
|
||||
// called by fiber_properties::notify() -- don't directly call
|
||||
virtual void property_change_( context * ctx, fiber_properties * props) noexcept = 0;
|
||||
|
||||
protected:
|
||||
static fiber_properties* get_properties( context * ctx) noexcept;
|
||||
static void set_properties( context * ctx, fiber_properties * p) noexcept;
|
||||
};
|
||||
|
||||
template< typename PROPS >
|
||||
struct algorithm_with_properties : public algorithm_with_properties_base {
|
||||
typedef algorithm_with_properties_base super;
|
||||
|
||||
// Mark this override 'final': algorithm_with_properties subclasses
|
||||
// must override awakened() with properties parameter instead. Otherwise
|
||||
// you'd have to remember to start every subclass awakened() override
|
||||
// with: algorithm_with_properties<PROPS>::awakened(fb);
|
||||
virtual void awakened( context * ctx) noexcept override final {
|
||||
fiber_properties * props = super::get_properties( ctx);
|
||||
if ( nullptr == props) {
|
||||
// TODO: would be great if PROPS could be allocated on the new
|
||||
// fiber's stack somehow
|
||||
props = new_properties( ctx);
|
||||
// It is not good for new_properties() to return 0.
|
||||
BOOST_ASSERT_MSG( props, "new_properties() must return non-NULL");
|
||||
// new_properties() must return instance of (a subclass of) PROPS
|
||||
BOOST_ASSERT_MSG( dynamic_cast< PROPS * >( props),
|
||||
"new_properties() must return properties class");
|
||||
super::set_properties( ctx, props);
|
||||
}
|
||||
// Set algo_ again every time this fiber becomes READY. That
|
||||
// handles the case of a fiber migrating to a new thread with a new
|
||||
// algorithm subclass instance.
|
||||
props->set_algorithm( this);
|
||||
|
||||
// Okay, now forward the call to subclass override.
|
||||
awakened( ctx, properties( ctx) );
|
||||
}
|
||||
|
||||
// subclasses override this method instead of the original awakened()
|
||||
virtual void awakened( context *, PROPS &) noexcept = 0;
|
||||
|
||||
// used for all internal calls
|
||||
PROPS & properties( context * ctx) noexcept {
|
||||
return static_cast< PROPS & >( * super::get_properties( ctx) );
|
||||
}
|
||||
|
||||
// override this to be notified by PROPS::notify()
|
||||
virtual void property_change( context * ctx, PROPS & props) noexcept {
|
||||
}
|
||||
|
||||
// implementation for algorithm_with_properties_base method
|
||||
void property_change_( context * ctx, fiber_properties * props) noexcept override final {
|
||||
property_change( ctx, * static_cast< PROPS * >( props) );
|
||||
}
|
||||
|
||||
// Override this to customize instantiation of PROPS, e.g. use a different
|
||||
// allocator. Each PROPS instance is associated with a particular
|
||||
// context.
|
||||
virtual fiber_properties * new_properties( context * ctx) {
|
||||
return new PROPS( ctx);
|
||||
}
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_SUFFIX
|
||||
#endif
|
||||
|
||||
#endif // BOOST_FIBERS_ALGO_ALGORITHM_H
|
||||
@@ -0,0 +1,69 @@
|
||||
// Copyright Oliver Kowalke 2013.
|
||||
// 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_FIBERS_ALGO_ROUND_ROBIN_H
|
||||
#define BOOST_FIBERS_ALGO_ROUND_ROBIN_H
|
||||
|
||||
#include <condition_variable>
|
||||
#include <chrono>
|
||||
#include <mutex>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#include <boost/fiber/algo/algorithm.hpp>
|
||||
#include <boost/fiber/context.hpp>
|
||||
#include <boost/fiber/detail/config.hpp>
|
||||
#include <boost/fiber/scheduler.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_PREFIX
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:4251)
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace fibers {
|
||||
namespace algo {
|
||||
|
||||
class BOOST_FIBERS_DECL round_robin : public algorithm {
|
||||
private:
|
||||
typedef scheduler::ready_queue_type rqueue_type;
|
||||
|
||||
rqueue_type rqueue_{};
|
||||
std::mutex mtx_{};
|
||||
std::condition_variable cnd_{};
|
||||
bool flag_{ false };
|
||||
|
||||
public:
|
||||
round_robin() = default;
|
||||
|
||||
round_robin( round_robin const&) = delete;
|
||||
round_robin & operator=( round_robin const&) = delete;
|
||||
|
||||
virtual void awakened( context *) noexcept;
|
||||
|
||||
virtual context * pick_next() noexcept;
|
||||
|
||||
virtual bool has_ready_fibers() const noexcept;
|
||||
|
||||
virtual void suspend_until( std::chrono::steady_clock::time_point const&) noexcept;
|
||||
|
||||
virtual void notify() noexcept;
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_SUFFIX
|
||||
#endif
|
||||
|
||||
#endif // BOOST_FIBERS_ALGO_ROUND_ROBIN_H
|
||||
@@ -0,0 +1,86 @@
|
||||
|
||||
// Copyright Nat Goodspeed + Oliver Kowalke 2015.
|
||||
// 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_FIBERS_ALGO_SHARED_WORK_H
|
||||
#define BOOST_FIBERS_ALGO_SHARED_WORK_H
|
||||
|
||||
#include <condition_variable>
|
||||
#include <chrono>
|
||||
#include <deque>
|
||||
#include <mutex>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#include <boost/fiber/algo/algorithm.hpp>
|
||||
#include <boost/fiber/context.hpp>
|
||||
#include <boost/fiber/detail/config.hpp>
|
||||
#include <boost/fiber/scheduler.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_PREFIX
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:4251)
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace fibers {
|
||||
namespace algo {
|
||||
|
||||
class BOOST_FIBERS_DECL shared_work : public algorithm {
|
||||
private:
|
||||
typedef std::deque< context * > rqueue_type;
|
||||
typedef scheduler::ready_queue_type lqueue_type;
|
||||
|
||||
static rqueue_type rqueue_;
|
||||
static std::mutex rqueue_mtx_;
|
||||
|
||||
lqueue_type lqueue_{};
|
||||
std::mutex mtx_{};
|
||||
std::condition_variable cnd_{};
|
||||
bool flag_{ false };
|
||||
bool suspend_{ false };
|
||||
|
||||
public:
|
||||
shared_work() = default;
|
||||
|
||||
shared_work( bool suspend) :
|
||||
suspend_{ suspend } {
|
||||
}
|
||||
|
||||
shared_work( shared_work const&) = delete;
|
||||
shared_work( shared_work &&) = delete;
|
||||
|
||||
shared_work & operator=( shared_work const&) = delete;
|
||||
shared_work & operator=( shared_work &&) = delete;
|
||||
|
||||
void awakened( context * ctx) noexcept;
|
||||
|
||||
context * pick_next() noexcept;
|
||||
|
||||
bool has_ready_fibers() const noexcept {
|
||||
std::unique_lock< std::mutex > lock{ rqueue_mtx_ };
|
||||
return ! rqueue_.empty() || ! lqueue_.empty();
|
||||
}
|
||||
|
||||
void suspend_until( std::chrono::steady_clock::time_point const& time_point) noexcept;
|
||||
|
||||
void notify() noexcept;
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_SUFFIX
|
||||
#endif
|
||||
|
||||
#endif // BOOST_FIBERS_ALGO_SHARED_WORK_H
|
||||
@@ -0,0 +1,84 @@
|
||||
|
||||
// Copyright Oliver Kowalke 2015.
|
||||
// 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_FIBERS_ALGO_WORK_STEALING_H
|
||||
#define BOOST_FIBERS_ALGO_WORK_STEALING_H
|
||||
|
||||
#include <condition_variable>
|
||||
#include <chrono>
|
||||
#include <cstddef>
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#include <boost/fiber/algo/algorithm.hpp>
|
||||
#include <boost/fiber/detail/context_spinlock_queue.hpp>
|
||||
#include <boost/fiber/detail/context_spmc_queue.hpp>
|
||||
#include <boost/fiber/context.hpp>
|
||||
#include <boost/fiber/detail/config.hpp>
|
||||
#include <boost/fiber/scheduler.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_PREFIX
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace fibers {
|
||||
namespace algo {
|
||||
|
||||
class work_stealing : public algorithm {
|
||||
private:
|
||||
static std::vector< work_stealing * > schedulers_;
|
||||
|
||||
std::size_t idx_;
|
||||
std::size_t max_idx_;
|
||||
#ifdef BOOST_FIBERS_USE_SPMC_QUEUE
|
||||
alignas(cache_alignment) detail::context_spmc_queue rqueue_{};
|
||||
#else
|
||||
alignas(cache_alignment) detail::context_spinlock_queue rqueue_{};
|
||||
#endif
|
||||
std::mutex mtx_{};
|
||||
std::condition_variable cnd_{};
|
||||
bool flag_{ false };
|
||||
bool suspend_;
|
||||
|
||||
static void init_( std::size_t max_idx);
|
||||
|
||||
public:
|
||||
work_stealing( std::size_t max_idx, std::size_t idx, bool suspend = false);
|
||||
|
||||
work_stealing( work_stealing const&) = delete;
|
||||
work_stealing( work_stealing &&) = delete;
|
||||
|
||||
work_stealing & operator=( work_stealing const&) = delete;
|
||||
work_stealing & operator=( work_stealing &&) = delete;
|
||||
|
||||
void awakened( context * ctx) noexcept;
|
||||
|
||||
context * pick_next() noexcept;
|
||||
|
||||
context * steal() noexcept {
|
||||
return rqueue_.steal();
|
||||
}
|
||||
|
||||
bool has_ready_fibers() const noexcept {
|
||||
return ! rqueue_.empty();
|
||||
}
|
||||
|
||||
void suspend_until( std::chrono::steady_clock::time_point const& time_point) noexcept;
|
||||
|
||||
void notify() noexcept;
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_SUFFIX
|
||||
#endif
|
||||
|
||||
#endif // BOOST_FIBERS_ALGO_WORK_STEALING_H
|
||||
Reference in New Issue
Block a user