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

Modify task counting in thread_queue.hpp #3242

Merged
merged 2 commits into from Mar 19, 2018
Merged
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
14 changes: 12 additions & 2 deletions hpx/runtime/threads/policies/thread_queue.hpp
Expand Up @@ -293,7 +293,7 @@ namespace hpx { namespace threads { namespace policies
++addfrom->new_tasks_wait_count_;
}
#endif
--addfrom->new_tasks_count_;


// measure thread creation time
util::block_profiler_wrapper<add_new_tag> bp(add_new_logger_);
Expand All @@ -312,14 +312,19 @@ namespace hpx { namespace threads { namespace policies
thread_map_.insert(thrd);

if (HPX_UNLIKELY(!p.second)) {
--addfrom->new_tasks_count_;
lk.unlock();
HPX_THROW_EXCEPTION(hpx::out_of_memory,
"threadmanager::add_new",
"Couldn't add new thread to the thread map");
return 0;
}

++thread_map_count_;

// Decrement only after thread_map_count_ has been incremented
--addfrom->new_tasks_count_;

// only insert the thread into the work-items queue if it is in
// pending state
if (state == pending) {
Expand Down Expand Up @@ -804,7 +809,7 @@ namespace hpx { namespace threads { namespace policies
task_description* task;
while (src->new_tasks_.pop(task))
{
--src->new_tasks_count_;


#ifdef HPX_HAVE_THREAD_QUEUE_WAITTIME
if (maintain_queue_wait_times) {
Expand All @@ -816,6 +821,11 @@ namespace hpx { namespace threads { namespace policies
#endif

bool finish = count == ++new_tasks_count_;

// Decrement only after the local new_tasks_count_ has
// been incremented
--src->new_tasks_count_;

if (new_tasks_.push(task))
{
if (finish)
Expand Down