Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing #1722 #1728

Merged
merged 18 commits into from Aug 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/CMakeLists.txt
Expand Up @@ -52,6 +52,7 @@ set(doxygen_dependencies
"${PROJECT_SOURCE_DIR}/hpx/error.hpp"
"${PROJECT_SOURCE_DIR}/hpx/exception.hpp"
"${PROJECT_SOURCE_DIR}/hpx/exception_list.hpp"
"${PROJECT_SOURCE_DIR}/hpx/lcos_fwd.hpp"
"${PROJECT_SOURCE_DIR}/hpx/components/component_storage/migrate_from_storage.hpp"
"${PROJECT_SOURCE_DIR}/hpx/components/component_storage/migrate_to_storage.hpp"
"${PROJECT_SOURCE_DIR}/hpx/parallel/execution_policy.hpp"
Expand Down Expand Up @@ -122,6 +123,7 @@ set(doxygen_dependencies
"${PROJECT_SOURCE_DIR}/hpx/runtime/components/new.hpp"
"${PROJECT_SOURCE_DIR}/hpx/runtime/naming/unmanaged.hpp"
"${PROJECT_SOURCE_DIR}/hpx/runtime/threads/thread_enums.hpp"
"${PROJECT_SOURCE_DIR}/hpx/runtime/threads_fwd.hpp"
"${PROJECT_SOURCE_DIR}/hpx/lcos/broadcast.hpp"
"${PROJECT_SOURCE_DIR}/hpx/lcos/fold.hpp"
"${PROJECT_SOURCE_DIR}/hpx/lcos/reduce.hpp"
Expand Down
2 changes: 1 addition & 1 deletion hpx/config/boost/compiler/intel.hpp
Expand Up @@ -240,7 +240,7 @@ template<> struct assert_intrinsic_wchar_t<unsigned short> {};
#if defined(BOOST_INTEL_STDCXX0X) && (BOOST_INTEL_CXX_VERSION > 1200)
# undef BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS
// std::nullptr seems to be enabled starting with gcc 4.4.7
#if defined(_MSC_VER) || (defined(__GNUC__) && !(__GNUC__ == 4
#if defined(_MSC_VER) || (defined(__GNUC__) && !(__GNUC__ == 4 \
&& __GNUC_MINOR__ == 4 && __GNUC_PATCHLEVEL__ <= 7))
# undef BOOST_NO_CXX11_NULLPTR
#endif
Expand Down
287 changes: 2 additions & 285 deletions hpx/hpx_fwd.hpp
Expand Up @@ -39,17 +39,17 @@

#include <hpx/traits.hpp>
#include <hpx/lcos/local/once_fwd.hpp>
#include <hpx/lcos_fwd.hpp>
#include <hpx/util/function.hpp>
// ^ this has to come before the naming/id_type.hpp below
#include <hpx/util/move.hpp>
#include <hpx/util/unique_function.hpp>
#include <hpx/util/unused.hpp>
#include <hpx/util/coroutine/detail/default_context_impl.hpp>
#include <hpx/util/coroutine/detail/coroutine_impl.hpp>
#include <hpx/runtime/launch_policy.hpp>
#include <hpx/runtime/threads_fwd.hpp>
#include <hpx/runtime/naming/id_type.hpp>
#include <hpx/runtime/threads/detail/tagged_thread_state.hpp>
#include <hpx/runtime/threads/thread_enums.hpp>

/// \cond NOINTERNAL
namespace boost
Expand Down Expand Up @@ -148,240 +148,6 @@ namespace hpx
HPX_API_EXPORT bool do_background_work(std::size_t num_thread = 0);
}

namespace util
{
namespace coroutines
{
namespace detail
{
template <typename Coroutine>
class coroutine_self;

template <typename CoroutineImpl>
struct coroutine_allocator;
template<typename CoroutineType, typename ContextImpl,
template <typename> class Heap>
class coroutine_impl;
}

template<typename Signature,
template <typename> class Heap,
typename ContextImpl = detail::default_context_impl>
class coroutine;
}
}

/// \namespace threads
///
/// The namespace \a thread-manager contains all the definitions required
/// for the scheduling, execution and general management of \a
/// hpx#threadmanager#thread's.
namespace threads
{
namespace policies
{
struct scheduler_base;

struct lockfree_fifo;
struct lockfree_lifo;

// multi priority scheduler with work-stealing
template <typename Mutex = boost::mutex
, typename PendingQueuing = lockfree_fifo
, typename StagedQueuing = lockfree_fifo
, typename TerminatedQueuing = lockfree_lifo
>
class HPX_EXPORT local_priority_queue_scheduler;

// single priority scheduler with work-stealing
template <typename Mutex = boost::mutex
, typename PendingQueuing = lockfree_fifo
, typename StagedQueuing = lockfree_fifo
, typename TerminatedQueuing = lockfree_lifo
>
class HPX_EXPORT local_queue_scheduler;

#if defined(HPX_HAVE_PERIODIC_PRIORITY_SCHEDULER)
template <typename Mutex = boost::mutex
, typename PendingQueuing = lockfree_fifo
, typename StagedQueuing = lockfree_fifo
, typename TerminatedQueuing = lockfree_lifo
>
class HPX_EXPORT periodic_priority_queue_scheduler;
#endif

#if defined(HPX_HAVE_STATIC_PRIORITY_SCHEDULER)
// multi priority scheduler with no work-stealing
template <typename Mutex = boost::mutex
, typename PendingQueuing = lockfree_fifo
, typename StagedQueuing = lockfree_fifo
, typename TerminatedQueuing = lockfree_lifo
>
class HPX_EXPORT static_priority_queue_scheduler;
#endif

#if defined(HPX_HAVE_STATIC_SCHEDULER)
// single priority scheduler with no work-stealing
template <typename Mutex = boost::mutex
, typename PendingQueuing = lockfree_fifo
, typename StagedQueuing = lockfree_fifo
, typename TerminatedQueuing = lockfree_lifo
>
class HPX_EXPORT static_queue_scheduler;
#endif

#if defined(HPX_HAVE_HIERARCHY_SCHEDULER)
template <typename Mutex = boost::mutex
, typename PendingQueuing = lockfree_fifo
, typename StagedQueuing = lockfree_fifo
, typename TerminatedQueuing = lockfree_lifo
>
class HPX_EXPORT hierarchy_scheduler;
#endif

typedef local_priority_queue_scheduler<
boost::mutex,
lockfree_fifo, // FIFO pending queuing
lockfree_fifo, // FIFO staged queuing
lockfree_lifo // LIFO terminated queuing
> fifo_priority_queue_scheduler;

#if defined(HPX_HAVE_ABP_SCHEDULER)
struct lockfree_abp_fifo;
struct lockfree_abp_lifo;

typedef local_priority_queue_scheduler<
boost::mutex,
lockfree_abp_fifo, // FIFO + ABP pending queuing
lockfree_abp_fifo, // FIFO + ABP staged queuing
lockfree_lifo // LIFO terminated queuing
> abp_fifo_priority_queue_scheduler;
#endif

// define the default scheduler to use
typedef fifo_priority_queue_scheduler queue_scheduler;

class HPX_EXPORT callback_notifier;
}

struct HPX_EXPORT threadmanager_base;
class HPX_EXPORT thread_data_base;
class HPX_EXPORT thread_data;

template <typename SchedulingPolicy>
class HPX_EXPORT threadmanager_impl;

typedef thread_state_enum thread_function_sig(thread_state_ex_enum);
typedef util::unique_function_nonser<thread_function_sig>
thread_function_type;

class HPX_EXPORT executor;

///////////////////////////////////////////////////////////////////////
/// \ cond NODETAIL
namespace detail
{
template <typename CoroutineImpl> struct coroutine_allocator;
}
/// \ endcond
typedef util::coroutines::coroutine<
thread_function_sig, detail::coroutine_allocator> coroutine_type;

typedef util::coroutines::detail::coroutine_self<coroutine_type>
thread_self;
typedef
util::coroutines::detail::coroutine_impl<
coroutine_type
, util::coroutines::detail::default_context_impl
, detail::coroutine_allocator
>
thread_self_impl_type;
typedef void * thread_id_repr_type;

typedef boost::intrusive_ptr<thread_data_base> thread_id_type;

HPX_EXPORT void intrusive_ptr_add_ref(thread_data_base* p);
HPX_EXPORT void intrusive_ptr_release(thread_data_base* p);

///////////////////////////////////////////////////////////////////////
/// \ cond NODETAIL
BOOST_CONSTEXPR_OR_CONST thread_id_repr_type invalid_thread_id_repr = 0;
thread_id_type const invalid_thread_id = thread_id_type();
/// \ endcond

/// The function \a get_self returns a reference to the (OS thread
/// specific) self reference to the current HPX thread.
HPX_API_EXPORT thread_self& get_self();

/// The function \a get_self_ptr returns a pointer to the (OS thread
/// specific) self reference to the current HPX thread.
HPX_API_EXPORT thread_self* get_self_ptr();

/// The function \a get_ctx_ptr returns a pointer to the internal data
/// associated with each coroutine.
HPX_API_EXPORT thread_self_impl_type* get_ctx_ptr();

/// The function \a get_self_ptr_checked returns a pointer to the (OS
/// thread specific) self reference to the current HPX thread.
HPX_API_EXPORT thread_self* get_self_ptr_checked(error_code& ec = throws);

/// The function \a get_self_id returns the HPX thread id of the current
/// thread (or zero if the current thread is not a HPX thread).
HPX_API_EXPORT thread_id_type get_self_id();

/// The function \a get_parent_id returns the HPX thread id of the
/// current thread's parent (or zero if the current thread is not a
/// HPX thread).
///
/// \note This function will return a meaningful value only if the
/// code was compiled with HPX_HAVE_THREAD_PARENT_REFERENCE
/// being defined.
HPX_API_EXPORT thread_id_repr_type get_parent_id();

/// The function \a get_parent_phase returns the HPX phase of the
/// current thread's parent (or zero if the current thread is not a
/// HPX thread).
///
/// \note This function will return a meaningful value only if the
/// code was compiled with HPX_HAVE_THREAD_PARENT_REFERENCE
/// being defined.
HPX_API_EXPORT std::size_t get_parent_phase();

/// The function \a get_parent_locality_id returns the id of the locality of
/// the current thread's parent (or zero if the current thread is not a
/// HPX thread).
///
/// \note This function will return a meaningful value only if the
/// code was compiled with HPX_HAVE_THREAD_PARENT_REFERENCE
/// being defined.
HPX_API_EXPORT boost::uint32_t get_parent_locality_id();

/// The function \a get_self_component_id returns the lva of the
/// component the current thread is acting on
///
/// \note This function will return a meaningful value only if the
/// code was compiled with HPX_HAVE_THREAD_TARGET_ADDRESS
/// being defined.
HPX_API_EXPORT boost::uint64_t get_self_component_id();

/// The function \a get_thread_manager returns a reference to the
/// current thread manager.
HPX_API_EXPORT threadmanager_base& get_thread_manager();

/// The function \a get_thread_count returns the number of currently
/// known threads.
///
/// \note If state == unknown this function will not only return the
/// number of currently existing threads, but will add the number
/// of registered task descriptions (which have not been
/// converted into threads yet).
HPX_API_EXPORT boost::int64_t get_thread_count(
thread_state_enum state = unknown);

/// \copydoc get_thread_count(thread_state_enum state)
HPX_API_EXPORT boost::int64_t get_thread_count(
thread_priority priority, thread_state_enum state = unknown);
}

class HPX_API_EXPORT runtime;
class HPX_API_EXPORT thread;
Expand Down Expand Up @@ -584,51 +350,6 @@ namespace hpx

HPX_EXPORT components::server::runtime_support* get_runtime_support_ptr();

/// \namespace lcos
namespace lcos
{
class base_lco;
template <typename Result, typename RemoteResult = Result>
class base_lco_with_value;

template <typename Result,
typename RemoteResult =
typename traits::promise_remote_result<Result>::type>
class promise;

template <typename Action,
typename Result = typename traits::promise_local_result<
typename Action::remote_result_type>::type,
typename DirectExecute = typename Action::direct_execution>
class packaged_action;

template <typename R>
class future;

template <typename R>
class shared_future;

template <typename ValueType>
struct object_semaphore;

namespace stubs
{
template <typename ValueType>
struct object_semaphore;
}

namespace server
{
template <typename ValueType>
struct object_semaphore;
}

namespace local
{
class barrier;
}
}

/// \namespace util
namespace util
{
Expand Down Expand Up @@ -682,10 +403,6 @@ namespace hpx
using naming::id_type;
using naming::invalid_id;

using lcos::future;
using lcos::shared_future;
using lcos::promise;

/// \endcond
}

Expand Down
4 changes: 4 additions & 0 deletions hpx/lcos/detail/future_data.hpp
Expand Up @@ -62,11 +62,15 @@ namespace detail
///////////////////////////////////////////////////////////////////////
struct future_data_refcnt_base
{
private:
typedef util::unique_function_nonser<void()> completed_callback_type;
public:
typedef void has_future_data_refcnt_base;

virtual ~future_data_refcnt_base() {}

virtual void set_on_completed(completed_callback_type) = 0;

virtual bool requires_delete()
{
return 0 == --count_;
Expand Down