File tree Expand file tree Collapse file tree 2 files changed +34
-2
lines changed
Expand file tree Collapse file tree 2 files changed +34
-2
lines changed Original file line number Diff line number Diff line change 1- // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
1+ // Copyright (c) 2021-2023 , NVIDIA CORPORATION & AFFILIATES . All rights reserved.
22//
33// Licensed under the Apache License, Version 2.0 (the "License");
44// you may not use this file except in compliance with the License.
@@ -46,7 +46,7 @@ class SequentialExecutionEngine {
4646 * @brief Immediately execute a callable object `f` with thread index 0.
4747 */
4848 template <typename FunctionLike>
49- void AddWork (FunctionLike &&f, int64_t priority = 0 , bool start_immediately = true ) {
49+ void AddWork (FunctionLike &&f, int64_t priority = 0 ) {
5050 const int idx = 0 ; // use of 0 literal would successfully call f expecting a pointer
5151 f (idx);
5252 }
Original file line number Diff line number Diff line change @@ -161,6 +161,38 @@ class DLL_PUBLIC ThreadPoolBase {
161161 std::vector<std::thread> threads_;
162162};
163163
164+
165+ template <typename ThreadPool>
166+ class ThreadedExecutionengine {
167+ public:
168+ ThreadedExecutionengine (ThreadPool &tp) : tp_(tp) {} // NOLINT
169+
170+ /* *
171+ * @brief Immediately execute a callable object `f` with thread index 0.
172+ */
173+ template <typename FunctionLike>
174+ void AddWork (FunctionLike &&f, int64_t priority = 0 ) {
175+ job_.AddTask (std::forward<FunctionLike>(f), priority);
176+ }
177+
178+ void RunAll () {
179+ job_.Run (tp_, true );
180+ }
181+
182+ int NumThreads () const noexcept {
183+ return tp_.NumThreads ();
184+ }
185+
186+ ThreadPool &GetThreadPool () const noexcept {
187+ return tp_;
188+ }
189+
190+ private:
191+ ThreadPool &tp_;
192+ Job job_;
193+ };
194+
195+
164196} // namespace dali
165197
166198#endif // DALI_CORE_EXEC_THREAD_POOL_BASE_H_
You can’t perform that action at this time.
0 commit comments