Skip to content

Commit 0a62c6f

Browse files
authored
Patch 0.5.2 (#31)
* reduce test load * update NEWS * submit to CRAN
1 parent 92d959d commit 0a62c6f

File tree

4 files changed

+26
-21
lines changed

4 files changed

+26
-21
lines changed

DESCRIPTION

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: RcppThread
22
Title: R-Friendly Threading in C++
3-
Version: 0.5.1
3+
Version: 0.5.2
44
Authors@R:
55
person("Thomas", "Nagler", email = "[email protected]", role = c("aut", "cre"))
66
Description: Provides a C++11-style thread class and thread pool that can safely
@@ -15,6 +15,6 @@ BugReports: https://github.com/tnagler/RcppThread/issues
1515
RoxygenNote: 6.1.0
1616
Suggests:
1717
testthat,
18-
Rcpp,
19-
R.rsp
18+
R.rsp,
19+
Rcpp
2020
VignetteBuilder: R.rsp

NEWS.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# RcppThread 0.5.2
2+
3+
* Limit number of threads in unit tests.
4+
5+
* Fixed typos in package vignette.
6+
7+
18
# RcppThread 0.5.1
29

310
BUG FIXES

tests/tests.cpp

+16-18
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void testThreadClass()
4949
// [[Rcpp::export]]
5050
void testThreadPoolPush()
5151
{
52-
ThreadPool pool;
52+
ThreadPool pool(2);
5353
std::vector<size_t> x(1000000, 1);
5454
auto dummy = [&] (size_t i) -> void {
5555
checkUserInterrupt();
@@ -71,7 +71,7 @@ void testThreadPoolPush()
7171
// [[Rcpp::export]]
7272
void testThreadPoolPushReturn()
7373
{
74-
ThreadPool pool;
74+
ThreadPool pool(2);
7575
std::vector<size_t> x(1000000, 1);
7676
auto dummy = [&] (size_t i) {
7777
checkUserInterrupt();
@@ -97,7 +97,7 @@ void testThreadPoolPushReturn()
9797
// [[Rcpp::export]]
9898
void testThreadPoolMap()
9999
{
100-
ThreadPool pool;
100+
ThreadPool pool(2);
101101

102102
std::vector<size_t> x(1000000, 1);
103103
auto dummy = [&] (size_t i) -> void {
@@ -123,7 +123,7 @@ void testThreadPoolMap()
123123
// [[Rcpp::export]]
124124
void testThreadPoolParallelFor()
125125
{
126-
ThreadPool pool;
126+
ThreadPool pool(2);
127127

128128
std::vector<size_t> x(1000000, 1);
129129
auto dummy = [&] (size_t i) -> void {
@@ -146,7 +146,7 @@ void testThreadPoolParallelFor()
146146
// [[Rcpp::export]]
147147
void testThreadPoolNestedParallelFor()
148148
{
149-
ThreadPool pool;
149+
ThreadPool pool(2);
150150
std::vector<std::vector<double>> x(100);
151151
for (auto &xx : x)
152152
xx = std::vector<double>(100, 1.0);
@@ -169,7 +169,7 @@ void testThreadPoolNestedParallelFor()
169169
// [[Rcpp::export]]
170170
void testThreadPoolParallelForEach()
171171
{
172-
ThreadPool pool;
172+
ThreadPool pool(2);
173173

174174
std::vector<size_t> x(1000000, 1);
175175
auto dummy = [&] (size_t i) -> void {
@@ -195,7 +195,7 @@ void testThreadPoolParallelForEach()
195195
// [[Rcpp::export]]
196196
void testThreadPoolNestedParallelForEach()
197197
{
198-
ThreadPool pool;
198+
ThreadPool pool(2);
199199

200200
std::vector<std::vector<double>> x(100);
201201
for (auto &xx : x)
@@ -243,7 +243,7 @@ void testThreadPoolSingleThreaded()
243243
// [[Rcpp::export]]
244244
void testThreadPoolDestructWOJoin()
245245
{
246-
ThreadPool pool;
246+
ThreadPool pool(2);
247247
}
248248

249249

@@ -256,7 +256,7 @@ void testParallelFor()
256256
x[i] = 2 * x[i];
257257
};
258258

259-
parallelFor(0, x.size() / 2, dummy);
259+
parallelFor(0, x.size() / 2, dummy, 2);
260260
parallelFor(0, x.size() / 2, dummy, 0);
261261

262262
size_t count_wrong = 0;
@@ -302,7 +302,7 @@ void testParallelForEach()
302302
auto ids = std::vector<size_t>(x.size() / 2);
303303
for (size_t i = 0; i < ids.size(); i++)
304304
ids[i] = i;
305-
parallelForEach(ids, dummy);
305+
parallelForEach(ids, dummy, 2);
306306
parallelForEach(ids, dummy, 0);
307307

308308
size_t count_wrong = 0;
@@ -319,15 +319,13 @@ void testNestedParallelForEach()
319319
{
320320
std::vector<std::vector<double>> x(1);
321321
for (auto &xx : x)
322-
xx = std::vector<double>(2, 1.0);
322+
xx = std::vector<double>(1, 1.0);
323323

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) {
327326
xxx *= 2;
328-
});
329-
});
330-
pool.join();
327+
}, 1);
328+
}, 1);
331329

332330
size_t count_wrong = 0;
333331
for (auto xx : x) {
@@ -354,7 +352,7 @@ void testNestedParallelForEach()
354352
// // [[Rcpp::export]]
355353
// void testThreadPoolInterruptJoin()
356354
// {
357-
// ThreadPool pool;
355+
// ThreadPool pool(2);
358356
// auto dummy = [] {
359357
// std::this_thread::sleep_for(std::chrono::milliseconds(500));
360358
// checkUserInterrupt();

vignettes/RcppThread-vignette.pdf

-17 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)