Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions libs/core/schedulers/include/hpx/schedulers/thread_queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,13 @@ namespace hpx::threads::policies {
if (delete_all)
{
// delete all threads
std::int64_t term_delta = 0;
std::int64_t map_delta = 0;
thread_data* to_delete;
while (terminated_items_.pop(to_delete))
{
++term_delta;
thread_id_type tid(to_delete);
--terminated_items_count_;

// this thread has to be managed by this queue, it may have
// ended up on the terminate threads list more than once,
Expand All @@ -406,10 +408,15 @@ namespace hpx::threads::policies {
if (thread_map_.erase(tid) != 0)
{
recycle_thread(tid);
--thread_map_count_;
HPX_ASSERT(thread_map_count_ >= 0);
++map_delta;
}
}
terminated_items_count_.fetch_sub(
term_delta, std::memory_order_acq_rel);
[[maybe_unused]] std::int64_t remaining =
Comment thread Dismissed
thread_map_count_.fetch_sub(
map_delta, std::memory_order_acq_rel);
HPX_ASSERT(remaining - map_delta >= 0);
}
else
{
Expand All @@ -424,11 +431,13 @@ namespace hpx::threads::policies {
delete_count = (std::max) (delete_count,
static_cast<std::int64_t>(parameters_.min_delete_count_));

std::int64_t term_delta = 0;
std::int64_t map_delta = 0;
thread_data* to_delete;
while (delete_count && terminated_items_.pop(to_delete))
{
++term_delta;
thread_id_type tid(to_delete);
--terminated_items_count_;

// this thread has to be managed by this queue, it may have
// ended up on the terminate threads list more than once,
Expand All @@ -440,11 +449,16 @@ namespace hpx::threads::policies {
if (thread_map_.erase(tid) != 0)
{
recycle_thread(tid);
--thread_map_count_;
HPX_ASSERT(thread_map_count_ >= 0);
++map_delta;
}
--delete_count;
}
terminated_items_count_.fetch_sub(
term_delta, std::memory_order_acq_rel);
[[maybe_unused]] std::int64_t remaining =
Comment thread Fixed
Comment thread Dismissed
thread_map_count_.fetch_sub(
map_delta, std::memory_order_acq_rel);
HPX_ASSERT(remaining - map_delta >= 0);
Comment thread Fixed
}
return terminated_items_count_.load(std::memory_order_acquire) == 0;
}
Expand Down
Loading