get_threads
C++ Function Reference
1 Signature
unsigned int BigDataStatMeth::get_threads(bool bparal, Rcpp::Nullable< int > threads=R_NilValue)2 Description
Determines number of threads for parallel operations.
3 Parameters
bparal(bool): Whether to use parallel processingthreads(Rcpp::Nullable< int >): Optional number of threads to use
4 Returns
unsigned int Number of threads to use
5 Details
bparalWhether to use parallel processing threadsOptional number of threads to use unsigned int Number of threads to use Thread determination:Considers hardware concurrencyRespects user-specified thread countFalls back to single thread if parallel disabledOptimizes for system resources
6 Call Graph
7 Source Code
NoteImplementation
File: inst/include/Utilities/Utilities.hpp • Lines 541-560
inline unsigned int get_threads(bool bparal, Rcpp::Nullable<int> threads = R_NilValue)
{
unsigned int ithreads = std::thread::hardware_concurrency();
if(bparal == false) {
ithreads = 1;
} else {
if(threads.isNotNull()) {
if ((unsigned)Rcpp::as<int> (threads) <= ithreads){
ithreads = Rcpp::as<int> (threads);
}
} else {
ithreads = getDTthreads(ithreads, false);
}
}
return(ithreads);
}8 Usage Example
#include "BigDataStatMeth.hpp"
// Example usage
auto result = get_threads(...);