Skip to content

Commit

Permalink
Merge pull request #3080 from msimberg/suspend-pool
Browse files Browse the repository at this point in the history
Suspend thread pool
  • Loading branch information
hkaiser committed Jan 17, 2018
2 parents 3507be4 + 0273adc commit 479520e
Show file tree
Hide file tree
Showing 20 changed files with 936 additions and 306 deletions.
21 changes: 21 additions & 0 deletions hpx/runtime/threads/detail/io_service_thread_pool.hpp
Expand Up @@ -9,6 +9,7 @@
#include <hpx/config.hpp>
#include <hpx/compat/barrier.hpp>
#include <hpx/compat/mutex.hpp>
#include <hpx/lcos/future.hpp>
#include <hpx/runtime/threads/detail/thread_pool_base.hpp>
#include <hpx/runtime/threads/policies/callback_notifier.hpp>
#include <hpx/runtime/threads/policies/scheduler_mode.hpp>
Expand Down Expand Up @@ -65,6 +66,26 @@ namespace hpx { namespace threads { namespace detail
///////////////////////////////////////////////////////////////////////
void stop (std::unique_lock<compat::mutex>& l, bool blocking = true);

///////////////////////////////////////////////////////////////////////
hpx::future<void> resume();
void resume_cb(std::function<void(void)> callback,
error_code& ec = throws);

hpx::future<void> suspend();
void suspend_cb(std::function<void(void)> callback,
error_code& ec = throws);

///////////////////////////////////////////////////////////////////////
hpx::future<void> suspend_processing_unit(std::size_t virt_core);
void suspend_processing_unit_cb(
std::function<void(void)> callback, std::size_t virt_core,
error_code& ec = throws);

hpx::future<void> resume_processing_unit(std::size_t virt_core);
void resume_processing_unit_cb(
std::function<void(void)> callback, std::size_t virt_core,
error_code& ec = throws);

///////////////////////////////////////////////////////////////////////
compat::thread& get_os_thread_handle(std::size_t global_thread_num);

Expand Down
20 changes: 16 additions & 4 deletions hpx/runtime/threads/detail/scheduled_thread_pool.hpp
Expand Up @@ -11,6 +11,7 @@
#include <hpx/compat/mutex.hpp>
#include <hpx/compat/thread.hpp>
#include <hpx/error_code.hpp>
#include <hpx/lcos/future.hpp>
#include <hpx/runtime/threads/detail/thread_pool_base.hpp>
#include <hpx/runtime/threads/policies/callback_notifier.hpp>
#include <hpx/runtime/threads/policies/scheduler_base.hpp>
Expand Down Expand Up @@ -131,9 +132,13 @@ namespace hpx { namespace threads { namespace detail

template <typename Lock>
void stop_locked(Lock& l, bool blocking = true);
void stop (std::unique_lock<compat::mutex>& l, bool blocking = true);
void stop(std::unique_lock<compat::mutex>& l, bool blocking = true);

void resume(error_code& ec = throws);
hpx::future<void> suspend();
void suspend_cb(std::function<void(void)> callback, error_code& ec = throws);

hpx::future<void> resume();
void resume_cb(std::function<void(void)> callback, error_code& ec = throws);

///////////////////////////////////////////////////////////////////
compat::thread& get_os_thread_handle(std::size_t global_thread_num)
Expand Down Expand Up @@ -267,14 +272,21 @@ namespace hpx { namespace threads { namespace detail
std::size_t virt_core, error_code& = hpx::throws);

// Suspend the given processing unit on the scheduler.
void suspend_processing_unit(std::size_t virt_core, error_code&);
hpx::future<void> suspend_processing_unit(std::size_t virt_core);
void suspend_processing_unit_cb(std::function<void(void)> callback,
std::size_t virt_core, error_code& = hpx::throws);

// Resume the given processing unit on the scheduler.
void resume_processing_unit(std::size_t virt_core, error_code&);
hpx::future<void> resume_processing_unit(std::size_t virt_core);
void resume_processing_unit_cb(std::function<void(void)> callback,
std::size_t virt_core, error_code& = hpx::throws);

protected:
friend struct init_tss_helper<Scheduler>;

void resume_internal(error_code& ec);
void suspend_internal(error_code& ec);

void remove_processing_unit_internal(
std::size_t virt_core, error_code& = hpx::throws);
void add_processing_unit_internal(std::size_t virt_core,
Expand Down

0 comments on commit 479520e

Please sign in to comment.