@@ -82,11 +82,11 @@ class WorkerThreadsPool
8282 * available. */
8383 template <class F , class ... Args>
8484 [[nodiscard]] auto enqueue (F&& f, Args&&... args)
85- -> std::future<typename std::result_of<F( Args...)>::type >;
85+ -> std::future<std::invoke_result_t<F, Args...> >;
8686
8787 /* * Returns the number of enqueued tasks, currently waiting for a free
8888 * working thread to process them. */
89- std::size_t pendingTasks () const noexcept ;
89+ [[nodiscard]] std::size_t pendingTasks () const noexcept ;
9090
9191 /* * Sets the private thread names of threads in this pool.
9292 * Names can be seen from debuggers, profilers, etc. and will follow
@@ -96,7 +96,7 @@ class WorkerThreadsPool
9696 void name (const std::string& name);
9797
9898 /* * Returns the base name of threads in this pool */
99- std::string name () const { return name_; }
99+ [[nodiscard]] std::string name () const { return name_; }
100100
101101 private:
102102 std::vector<std::thread> threads_;
@@ -110,16 +110,16 @@ class WorkerThreadsPool
110110
111111template <class F , class ... Args>
112112auto WorkerThreadsPool::enqueue (F&& f, Args&&... args)
113- -> std::future<typename std::result_of<F( Args...)>::type >
113+ -> std::future<std::invoke_result_t<F, Args...> >
114114{
115- using return_type = typename std::result_of< F ( Args...)>::type ;
115+ using return_type = std::invoke_result_t <F, Args...> ;
116116
117117 auto task = std::make_shared<std::packaged_task<return_type ()>>(
118118 std::bind (std::forward<F>(f), std::forward<Args>(args)...));
119119
120120 std::future<return_type> res = task->get_future ();
121121 {
122- std::unique_lock<std::mutex> lock (queue_mutex_);
122+ const std::unique_lock<std::mutex> lock (queue_mutex_);
123123
124124 // don't allow enqueueing after stopping the pool
125125 if (do_stop_) throw std::runtime_error (" enqueue on stopped ThreadPool" );
0 commit comments