Skip to content

Commit

Permalink
Custom pool executor was missing priority and stacksize options
Browse files Browse the repository at this point in the history
  • Loading branch information
biddisco committed Oct 1, 2017
1 parent a8cd28f commit f5d3037
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 8 deletions.
18 changes: 18 additions & 0 deletions hpx/runtime/threads/executors/customized_pool_executors.hpp
Expand Up @@ -30,6 +30,13 @@ namespace hpx { namespace threads { namespace executors
public:
customized_pool_executor(const std::string& pool_name);

customized_pool_executor(const std::string& pool_name,
thread_stacksize stacksize);

customized_pool_executor(const std::string& pool_name,
thread_priority priority,
thread_stacksize stacksize = thread_stacksize_default);

// Schedule the specified function for execution in this executor.
// Depending on the subclass implementation, this may block in some
// situations.
Expand Down Expand Up @@ -75,6 +82,10 @@ namespace hpx { namespace threads { namespace executors
// the scheduler used by this executor
pool_type& pool_;

// task properties
thread_stacksize stacksize_;
thread_priority priority_;

// protect scheduler initialization
typedef compat::mutex mutex_type;
mutable mutex_type mtx_;
Expand All @@ -85,6 +96,13 @@ namespace hpx { namespace threads { namespace executors
struct HPX_EXPORT customized_pool_executor : public scheduled_executor
{
customized_pool_executor(const std::string& pool_name);

customized_pool_executor(const std::string& pool_name,
thread_stacksize stacksize);

customized_pool_executor(const std::string& pool_name,
thread_priority priority,
thread_stacksize stacksize = thread_stacksize_default);
};
}}}

Expand Down
48 changes: 40 additions & 8 deletions src/runtime/threads/executors/customized_pool_executors.cpp
Expand Up @@ -20,12 +20,24 @@ namespace hpx { namespace threads { namespace executors
{
customized_pool_executor::customized_pool_executor(
std::string const& pool_name)
: pool_(hpx::threads::get_thread_manager().get_pool(pool_name))
{
//! FIXME
//! throw exception if name = default: tell them to use default_executor
//! throw exception if above = nullptr
}
: pool_(hpx::threads::get_thread_manager().get_pool(pool_name))
, stacksize_(thread_stacksize_default)
, priority_(thread_priority_default)
{}

customized_pool_executor::customized_pool_executor(const std::string& pool_name,
thread_stacksize stacksize)
: pool_(hpx::threads::get_thread_manager().get_pool(pool_name))
, stacksize_(stacksize)
, priority_(thread_priority_default)
{}

customized_pool_executor::customized_pool_executor(const std::string& pool_name,
thread_priority priority, thread_stacksize stacksize)
: pool_(hpx::threads::get_thread_manager().get_pool(pool_name))
, stacksize_(stacksize)
, priority_(priority)
{}

threads::thread_result_type
customized_pool_executor::thread_function_nullary(closure_type func)
Expand Down Expand Up @@ -62,7 +74,11 @@ namespace hpx { namespace threads { namespace executors
&customized_pool_executor::thread_function_nullary),
std::move(f)),
desc);

if (stacksize == threads::thread_stacksize_default)
stacksize = stacksize_;
data.stacksize = threads::get_stack_size(stacksize);
data.priority = priority_;

threads::thread_id_type id = threads::invalid_thread_id;
pool_.create_thread(data, id, initial_state, run_now, ec);
Expand Down Expand Up @@ -90,7 +106,11 @@ namespace hpx { namespace threads { namespace executors
&customized_pool_executor::thread_function_nullary),
std::move(f)),
desc);

if (stacksize == threads::thread_stacksize_default)
stacksize = stacksize_;
data.stacksize = threads::get_stack_size(stacksize);
data.priority = priority_;

threads::thread_id_type id = threads::invalid_thread_id;
pool_.create_thread(data, id, suspended, true, ec);
Expand Down Expand Up @@ -146,6 +166,18 @@ namespace hpx { namespace threads { namespace executors
customized_pool_executor::customized_pool_executor(
const std::string& pool_name)
: scheduled_executor(new detail::customized_pool_executor(pool_name))
{
}
{}

customized_pool_executor::customized_pool_executor(const std::string& pool_name,
thread_stacksize stacksize)
: scheduled_executor(new detail::customized_pool_executor(pool_name, stacksize))
{}

customized_pool_executor::customized_pool_executor(const std::string& pool_name,
thread_priority priority, thread_stacksize stacksize)
: scheduled_executor(
new detail::customized_pool_executor(pool_name, priority, stacksize))
{}


}}}

0 comments on commit f5d3037

Please sign in to comment.