@@ -49,7 +49,7 @@ void testThreadClass()
49
49
// [[Rcpp::export]]
50
50
void testThreadPoolPush ()
51
51
{
52
- ThreadPool pool;
52
+ ThreadPool pool ( 2 ) ;
53
53
std::vector<size_t > x (1000000 , 1 );
54
54
auto dummy = [&] (size_t i) -> void {
55
55
checkUserInterrupt ();
@@ -71,7 +71,7 @@ void testThreadPoolPush()
71
71
// [[Rcpp::export]]
72
72
void testThreadPoolPushReturn ()
73
73
{
74
- ThreadPool pool;
74
+ ThreadPool pool ( 2 ) ;
75
75
std::vector<size_t > x (1000000 , 1 );
76
76
auto dummy = [&] (size_t i) {
77
77
checkUserInterrupt ();
@@ -97,7 +97,7 @@ void testThreadPoolPushReturn()
97
97
// [[Rcpp::export]]
98
98
void testThreadPoolMap ()
99
99
{
100
- ThreadPool pool;
100
+ ThreadPool pool ( 2 ) ;
101
101
102
102
std::vector<size_t > x (1000000 , 1 );
103
103
auto dummy = [&] (size_t i) -> void {
@@ -123,7 +123,7 @@ void testThreadPoolMap()
123
123
// [[Rcpp::export]]
124
124
void testThreadPoolParallelFor ()
125
125
{
126
- ThreadPool pool;
126
+ ThreadPool pool ( 2 ) ;
127
127
128
128
std::vector<size_t > x (1000000 , 1 );
129
129
auto dummy = [&] (size_t i) -> void {
@@ -146,7 +146,7 @@ void testThreadPoolParallelFor()
146
146
// [[Rcpp::export]]
147
147
void testThreadPoolNestedParallelFor ()
148
148
{
149
- ThreadPool pool;
149
+ ThreadPool pool ( 2 ) ;
150
150
std::vector<std::vector<double >> x (100 );
151
151
for (auto &xx : x)
152
152
xx = std::vector<double >(100 , 1.0 );
@@ -169,7 +169,7 @@ void testThreadPoolNestedParallelFor()
169
169
// [[Rcpp::export]]
170
170
void testThreadPoolParallelForEach ()
171
171
{
172
- ThreadPool pool;
172
+ ThreadPool pool ( 2 ) ;
173
173
174
174
std::vector<size_t > x (1000000 , 1 );
175
175
auto dummy = [&] (size_t i) -> void {
@@ -195,7 +195,7 @@ void testThreadPoolParallelForEach()
195
195
// [[Rcpp::export]]
196
196
void testThreadPoolNestedParallelForEach ()
197
197
{
198
- ThreadPool pool;
198
+ ThreadPool pool ( 2 ) ;
199
199
200
200
std::vector<std::vector<double >> x (100 );
201
201
for (auto &xx : x)
@@ -243,7 +243,7 @@ void testThreadPoolSingleThreaded()
243
243
// [[Rcpp::export]]
244
244
void testThreadPoolDestructWOJoin ()
245
245
{
246
- ThreadPool pool;
246
+ ThreadPool pool ( 2 ) ;
247
247
}
248
248
249
249
@@ -256,7 +256,7 @@ void testParallelFor()
256
256
x[i] = 2 * x[i];
257
257
};
258
258
259
- parallelFor (0 , x.size () / 2 , dummy);
259
+ parallelFor (0 , x.size () / 2 , dummy, 2 );
260
260
parallelFor (0 , x.size () / 2 , dummy, 0 );
261
261
262
262
size_t count_wrong = 0 ;
@@ -302,7 +302,7 @@ void testParallelForEach()
302
302
auto ids = std::vector<size_t >(x.size () / 2 );
303
303
for (size_t i = 0 ; i < ids.size (); i++)
304
304
ids[i] = i;
305
- parallelForEach (ids, dummy);
305
+ parallelForEach (ids, dummy, 2 );
306
306
parallelForEach (ids, dummy, 0 );
307
307
308
308
size_t count_wrong = 0 ;
@@ -319,15 +319,13 @@ void testNestedParallelForEach()
319
319
{
320
320
std::vector<std::vector<double >> x (1 );
321
321
for (auto &xx : x)
322
- xx = std::vector<double >(2 , 1.0 );
322
+ xx = std::vector<double >(1 , 1.0 );
323
323
324
- ThreadPool pool;
325
- pool.parallelForEach (x, [&] (std::vector<double >& xx) {
326
- pool.parallelForEach (xx, [&] (double & xxx) {
324
+ parallelForEach (x, [&] (std::vector<double >& xx) {
325
+ parallelForEach (xx, [&] (double & xxx) {
327
326
xxx *= 2 ;
328
- });
329
- });
330
- pool.join ();
327
+ }, 1 );
328
+ }, 1 );
331
329
332
330
size_t count_wrong = 0 ;
333
331
for (auto xx : x) {
@@ -354,7 +352,7 @@ void testNestedParallelForEach()
354
352
// // [[Rcpp::export]]
355
353
// void testThreadPoolInterruptJoin()
356
354
// {
357
- // ThreadPool pool;
355
+ // ThreadPool pool(2) ;
358
356
// auto dummy = [] {
359
357
// std::this_thread::sleep_for(std::chrono::milliseconds(500));
360
358
// checkUserInterrupt();
0 commit comments