Skip to content

Commit

Permalink
chore(parallel): update BS::threadpool library v5
Browse files Browse the repository at this point in the history
  • Loading branch information
Nelson-numerical-software committed Jan 2, 2025
1 parent 7b91086 commit 782e0cd
Show file tree
Hide file tree
Showing 5 changed files with 2,412 additions and 432 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Help Center: Access documentation in your system's web browser. Previously, the documentation was opened in the embedded Help browser.
- CA certificate store update.
- fmt library dependency updated.
- BS::threadpool library dependency updated.
- Advanced terminal updated (common for all platforms without GUI, auto completion, search history).

## 1.10.0 (2024-12-14)
Expand Down
8 changes: 6 additions & 2 deletions modules/parallel/builtin/cpp/Gateway.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,13 @@ static bool
finishParallelModule(Nelson::Evaluator* eval)
{
if (BackgroundPoolObject::isInitialized()) {
BackgroundPoolObject::getInstance()->resetThreadPool();
size_t nbQueued = BackgroundPoolObject::getInstance()->getTasksQueued();
//BackgroundPoolObject::getInstance()->resetThreadPool();
if (nbQueued > 0) {
std::this_thread::sleep_for(std::chrono::seconds(5));
}
return true;
}
return true;
}
//=============================================================================
NLSGATEWAYFUNC(gateway)
Expand Down
7 changes: 4 additions & 3 deletions modules/parallel/src/cpp/BackgroundPoolObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ BackgroundPoolObject::getNumberOfThreads()
BackgroundPoolObject::BackgroundPoolObject()
: HandleGenericObject(NLS_HANDLE_BACKGROUNDPOOL_CATEGORY_STR, this, false)
{
threadPool = new BS::thread_pool(NelsonConfiguration::getInstance()->getMaxNumCompThreads());
threadPool
= new BS::pause_thread_pool(NelsonConfiguration::getInstance()->getMaxNumCompThreads());
propertiesNames = { L"NumWorkers", L"Busy", L"FevalQueue" };
}
//=============================================================================
Expand Down Expand Up @@ -154,8 +155,8 @@ BackgroundPoolObject::feval(FunctionDef* fptr, int nLhs, const ArrayOfVector& ar
} catch (std::bad_alloc&) {
Error(ERROR_MEMORY_ALLOCATION);
}

threadPool->push_task(&FevalFutureObject::evaluateFunction, retFuture, fptr, nLhs, argIn, true);
auto future = threadPool->submit_task(
[retFuture, fptr, nLhs, argIn]() { retFuture->evaluateFunction(fptr, nLhs, argIn, true); });
FevalQueueObject::getInstance()->add(retFuture);
ArrayOf result = ArrayOf::handleConstructor(retFuture);
nelson_handle* qp = (nelson_handle*)(result.getDataPointer());
Expand Down
Loading

0 comments on commit 782e0cd

Please sign in to comment.