Skip to content

Commit

Permalink
Merge pull request #3242 from STEllAR-GROUP/msimberg-patch-1
Browse files Browse the repository at this point in the history
Modify task counting in thread_queue.hpp
  • Loading branch information
msimberg committed Mar 19, 2018
2 parents 09eeee3 + d6a2555 commit f1a3454
Showing 1 changed file with 12 additions and 2 deletions.
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

0 comments on commit f1a3454

Please sign in to comment.