Example #1
0
        /// Return the next thread to be executed, return false if non is
        /// available
        bool get_next_thread(threads::thread_data_base*& thrd, std::size_t num_thread)
        {
#if HPX_THREAD_MAINTAIN_QUEUE_WAITTIME
            thread_description* tdesc;
            if (work_items_.dequeue(tdesc))
            {
                --work_items_count_;

                if (maintain_queue_wait_times) {
                    work_items_wait_ += util::high_resolution_clock::now() -
                        HPX_STD_GET(1, *tdesc);
                    ++work_items_wait_count_;
                }

                thrd = HPX_STD_GET(0, *tdesc);
                delete tdesc;

                return true;
            }
#else
            if (work_items_.dequeue(thrd))

            {
                --work_items_count_;
                return true;
            }
#endif
            return false;
        }
Example #2
0
 result_type operator()(
     hpx::lcos::future<data_type> data
 ) const
 {
     data_type v = data.move();
     std::cout << HPX_STD_GET(0, v).get() << "\n";
     std::cout << HPX_STD_GET(1, v).get() << "\n";
     std::cout << HPX_STD_GET(2, v).get() << "\n";
 }
Example #3
0
 int any() {
     if(vec.size()==0) {
         return 0;
     }
     result_type r = hpx::wait_any(vec);
     int i = HPX_STD_GET(0,r);
     vec.erase(vec.begin()+i);
     return i;
 }
Example #4
0
        void move_work_items_from(global_thread_queue *src,
            boost::int64_t count, std::size_t num_thread)
        {
            thread_description* trd;
            while (src->work_items_.dequeue(trd))
            {
                --src->work_items_count_;
#if HPX_THREAD_MAINTAIN_QUEUE_WAITTIME
                if (maintain_queue_wait_times) {
                    boost::uint64_t now = util::high_resolution_clock::now();
                    src->work_items_wait_ += now - HPX_STD_GET(1, *trd);
                    ++src->work_items_wait_count_;
                    HPX_STD_GET(1, *trd) = now;
                }
#endif
                work_items_.enqueue(trd);
                if (count == ++work_items_count_)
                    break;
            }
        }
Example #5
0
        void move_task_items_from(global_thread_queue *src,
            boost::int64_t count)
        {
            task_description* task;
            while (src->new_tasks_.dequeue(task))
            {
                --src->new_tasks_count_;

#if HPX_THREAD_MAINTAIN_QUEUE_WAITTIME
                if (maintain_queue_wait_times) {
                    boost::int64_t now = util::high_resolution_clock::now();
                    src->new_tasks_wait_ += now - HPX_STD_GET(2, *task);
                    ++src->new_tasks_wait_count_;
                    HPX_STD_GET(2, *task) = now;
                }
#endif

                if (new_tasks_.enqueue(task))
                {
                    if (count == ++new_tasks_count_)
                        break;
                }
            }
        }