Пример #1
0
            void operator()(Future& future) const
            {
                std::size_t counter = when_->count_.load(boost::memory_order_seq_cst);
                if (counter < when_->needed_count_ && !future.is_ready()) {
                    // handle future only if not enough futures are ready yet
                    // also, do not touch any futures which are already ready

                    typedef
                        typename lcos::detail::shared_state_ptr_for<Future>::type
                        shared_state_ptr;

                    shared_state_ptr const& shared_state =
                        lcos::detail::get_shared_state(future);

                    shared_state->set_on_completed(util::bind(
                        &set_when_each_on_completed_callback_impl::on_future_ready<Future>,
                        boost::ref(future), when_, threads::get_self_id()));
                }
                else {
                    if (when_->count_.fetch_add(1) + 1 == when_->needed_count_)
                    {
                        when_->goal_reached_on_calling_thread_ = true;
                    }
                    when_->f_(std::move(future));    // invoke callback right away
                }
            }
Пример #2
0
        void await_future(Future const & f)
        {
            if(f.is_ready()) return;

            buffer_->await_future(
                *hpx::traits::future_access<Future>::get_shared_state(f));
        }