Skip to content

Commit

Permalink
Merge pull request #1518 from STEllAR-GROUP/fix-when-some
Browse files Browse the repository at this point in the history
Fix when_some bug missing indices in its result
  • Loading branch information
K-ballo committed May 18, 2015
2 parents b11d5d9 + f0e043a commit f0b9f96
Show file tree
Hide file tree
Showing 6 changed files with 1,224 additions and 963 deletions.
21 changes: 11 additions & 10 deletions hpx/lcos/when_some.hpp
Expand Up @@ -370,18 +370,19 @@ namespace hpx { namespace lcos
public:
void on_future_ready(std::size_t idx, threads::thread_id_type const& id)
{
if (count_.fetch_add(1) + 1 == needed_count_)
std::size_t const new_count = count_.fetch_add(1) + 1;
if (new_count <= needed_count_)
{
// reactivate waiting thread only if it's not us
if (id != threads::get_self_id()) {
{
typename mutex_type::scoped_lock l(this->mtx_);
lazy_values_.indices.push_back(idx);
}
threads::set_thread_state(id, threads::pending);
} else {
{
typename mutex_type::scoped_lock l(this->mtx_);
lazy_values_.indices.push_back(idx);
goal_reached_on_calling_thread_ = true;
}
if (new_count == needed_count_) {
if (id != threads::get_self_id()) {
threads::set_thread_state(id, threads::pending);
} else {
goal_reached_on_calling_thread_ = true;
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/lcos/CMakeLists.txt
Expand Up @@ -36,6 +36,9 @@ set(tests
reduce
shared_future
unwrapped
when_all
when_any
when_some
)

set(apply_colocated_PARAMETERS LOCALITIES 2)
Expand Down

0 comments on commit f0b9f96

Please sign in to comment.