Skip to content

Commit

Permalink
Save
Browse files Browse the repository at this point in the history
  • Loading branch information
victimsnino committed May 22, 2023
1 parent 60c30ed commit 4bdb7b2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/rpp/rpp/schedulers/details/queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class specific_schedulable final : public schedulable_base
return std::nullopt;
}
}
bool is_disposed() const override { return std::get<0>(m_args).is_disposed(); }
bool is_disposed() const override { return std::get<0>(m_args).is_disposed(); }

private:
std::tuple<TObs, Args...> m_args;
Expand Down
16 changes: 10 additions & 6 deletions src/rpp/rpp/schedulers/new_thread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,17 @@ class new_thread
if (is_disposed.test(std::memory_order_relaxed))
break;

if (!cv.wait_until(lock,
queue_ptr->top()->get_timepoint(),
[&]
{
return is_disposed.test(std::memory_order_relaxed) || queue_ptr->top()->get_timepoint() <= clock_type::now();
}))
if (queue_ptr->top()->is_disposed())
{
queue_ptr->pop();
continue;
}

if (const auto now = clock_type::now(); now < queue_ptr->top()->get_timepoint())
{
cv.wait_for(lock, queue_ptr->top()->get_timepoint() - now);
continue;
}

auto top = queue_ptr->pop();

Expand Down

0 comments on commit 4bdb7b2

Please sign in to comment.