Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 106b68d

Browse files
authored
Use lock-free queue (tnagler#50)
* implement ring buffer * layout for TaskQueue * simplify * draft implementation * don't print empty strings * unit test for task queue * fix queue enlargement * avoid task copies * pop() <- steal() * use TaskQueue in thread pool * reduce locks * import moody camel project * new thread pool logic * update tests * add consumer tokens * clean up * clean moodyCamel header * rethrow exceptions * minor optimization * use larger blocksize * or not * move jobs * add benchmarks * more kendall bench runs * faster init through delayed thread spin up * not worth it * optimizations * update tests * remove unneccessary struct * clean up * try fix OSX build * nightmare avoided
1 parent 0cc5aa8 commit 106b68d

13 files changed

+5528
-166
lines changed

.Rbuildignore

+2
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ inst/include/mainpage.h
1212
revdep
1313
^\.github$
1414
^CRAN-RELEASE$
15+
.vscode/
16+
new-benchmarks.R

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
inst/doc
55
revdep
66
__pycache__
7+
.vscode/
8+
new-benchmarks.R

DESCRIPTION

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ Description: Provides a C++11-style thread class and thread pool that can safely
88
Depends: R (>= 3.3.0)
99
License: MIT + file LICENSE
1010
Encoding: UTF-8
11-
LazyData: true
1211
SystemRequirements: C++11
1312
URL: https://github.com/tnagler/RcppThread
1413
BugReports: https://github.com/tnagler/RcppThread/issues

NEWS.md

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* Add classes `ProgressCounter` and `ProgressBar` for tracking progress in long-
66
running loops (#49).
77

8+
* Increased speed for short running tasks due to lock-free queue (#50).
9+
810

911
# RcppThread 1.0.0
1012

inst/include/RcppThread/RMonitor.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class RMonitor {
7474
}
7575
}
7676

77-
//! checks for user interruptions, but only if called from main thread
77+
//! checks for user interruptions, but only if called from main thread
7878
//! (otherwise last known state is returned).
7979
bool safelyIsInterrupted()
8080
{
@@ -91,7 +91,7 @@ class RMonitor {
9191
{
9292
std::lock_guard<std::mutex> lk(m_);
9393
msgs_ << object;
94-
if ( calledFromMainThread() ) {
94+
if ( calledFromMainThread() && (msgs_.str() != std::string("")) ) {
9595
// release messages in buffer
9696
Rprintf("%s", msgs_.str().c_str());
9797
R_FlushConsole();

0 commit comments

Comments
 (0)