void thread_pool_attached_executor<Scheduler>::add(closure_type && f,
        char const* desc, threads::thread_state_enum initial_state,
        bool run_now, threads::thread_stacksize stacksize, error_code& ec)
    {
        if (stacksize == threads::thread_stacksize_default)
            stacksize = stacksize_;

        register_thread_nullary(std::move(f), desc, initial_state, run_now,
            priority_, get_next_thread_num(), stacksize, ec);
    }
示例#2
0
 void thread_pool_executor<Scheduler>::add_processing_unit(
     std::size_t virt_core, std::size_t thread_num, error_code& ec)
 {
     state expected = initialized;
     if (states_[virt_core].compare_exchange_strong(expected, starting))
     {
         register_thread_nullary(
             util::bind(
                 util::one_shot(&thread_pool_executor::run),
                 this, virt_core, thread_num
             ),
             "thread_pool_executor thread", threads::pending, true,
             threads::thread_priority_normal, thread_num,
             threads::thread_stacksize_default, ec);
     }
 }
示例#3
0
    void thread_pool_executor<Scheduler>::add_processing_unit(
        std::size_t virt_core, std::size_t thread_num, error_code& ec)
    {
        lcos::local::barrier b(2);
        register_thread_nullary(
            util::bind(
                &thread_pool_executor::run, this,
                virt_core, thread_num, boost::ref(b)
            ),
            "thread_pool_executor thread", threads::pending, true,
            threads::thread_priority_normal, thread_num,
            threads::thread_stacksize_default, ec);

        // wait for the thread to actually run
        b.wait();
    }
    void thread_pool_attached_executor<Scheduler>::add_at(
        boost::chrono::steady_clock::time_point const& abs_time,
        closure_type && f, char const* description,
        threads::thread_stacksize stacksize, error_code& ec)
    {
        if (stacksize == threads::thread_stacksize_default)
            stacksize = stacksize_;

        // create new thread
        thread_id_type id = register_thread_nullary(
            std::move(f), description, suspended, false,
            priority_, get_next_thread_num(), stacksize, ec);
        if (ec) return;

        HPX_ASSERT(invalid_thread_id != id);    // would throw otherwise

        // now schedule new thread for execution
        set_thread_state(id, abs_time);
    }