예제 #1
0
파일: pool.hpp 프로젝트: 7ute/osrm-backend
            std::future<typename std::result_of<TFunction()>::type> submit(TFunction&& func) {

                typedef typename std::result_of<TFunction()>::type result_type;

                std::packaged_task<result_type()> task(std::forward<TFunction>(func));
                std::future<result_type> future_result(task.get_future());
                m_work_queue.push(std::move(task));

                return future_result;
            }
예제 #2
0
 inline void add_to_queue(osmium::thread::Queue<std::future<T>>& queue, std::exception_ptr&& exception) {
     std::promise<T> promise;
     queue.push(promise.get_future());
     promise.set_exception(std::move(exception));
 }
예제 #3
0
파일: pool.hpp 프로젝트: 7ute/osrm-backend
 void shutdown_all_workers() {
     for (int i = 0; i < m_num_threads; ++i) {
         // The special function wrapper makes a worker shut down.
         m_work_queue.push(function_wrapper{0});
     }
 }
예제 #4
0
 inline void add_to_queue(osmium::thread::Queue<std::future<T>>& queue, T&& data) {
     std::promise<T> promise;
     queue.push(promise.get_future());
     promise.set_value(std::forward<T>(data));
 }