File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -118,21 +118,21 @@ void openmp(const std::vector<size_t>& D) {
118118 std::cout << " Generating matrix As ...\n " ;
119119 std::vector<matrix_t > As (D.size ());
120120 #pragma omp parallel for
121- for (size_t j=0 ; j<D.size (); ++j) {
121+ for (int j=0 ; j<D.size (); ++j) {
122122 As[j] = random_matrix (D[j]);
123123 }
124124
125125 std::cout << " Generating matrix Bs ...\n " ;
126126 std::vector<matrix_t > Bs (D.size ());
127127 #pragma omp parallel for
128- for (size_t j=0 ; j<D.size (); ++j) {
128+ for (int j=0 ; j<D.size (); ++j) {
129129 Bs[j] = random_matrix (D[j]);
130130 }
131131
132132 std::cout << " Computing matrix product values Cs ...\n " ;
133133 std::vector<matrix_t > Cs (D.size ());
134134 #pragma omp parallel for
135- for (size_t j=0 ; j<D.size (); ++j) {
135+ for (int j=0 ; j<D.size (); ++j) {
136136 Cs[j] = As[j] * Bs[j];
137137 }
138138
Original file line number Diff line number Diff line change @@ -250,6 +250,18 @@ auto Threadpool::silent_async(C&& c, Signal sig) {
250250 }
251251}
252252
253+ template <typename T, typename C>
254+ void set_promise_value (std::promise<T>& p, C &c)
255+ {
256+ p.set_value (c ());
257+ }
258+ template < typename C>
259+ void set_promise_value (std::promise<void >& p, C &c)
260+ {
261+ p.set_value ();
262+ }
263+
264+
253265// Function: async
254266// Insert a callable task and return a future representing the task.
255267template <typename C>
@@ -276,13 +288,17 @@ auto Threadpool::async(C&& c, Signal sig) {
276288 std::unique_lock lock (_mutex);
277289 _task_queue.emplace_back (
278290 [p=MoveOnCopy (std::move (p)), c=std::forward<C>(c), ret=sig] () mutable {
291+
292+ // VS compile fix
293+ set_promise_value (p.get (), c);
294+ /*
279295 if constexpr(std::is_same_v<void, R>) {
280296 c();
281297 p.get().set_value();
282298 }
283299 else {
284300 p.get().set_value(c());
285- }
301+ }*/
286302 return ret;
287303 }
288304 );
You can’t perform that action at this time.
0 commit comments