Skip to content
Snippets Groups Projects
Commit f751adac authored by Florian Schmaus's avatar Florian Schmaus
Browse files

[SimplestFibTest] Run Runtime destructor and allow worker count reduction

parent f9891762
No related branches found
No related tags found
No related merge requests found
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright © 2020 Florian Schmaus
// Copyright © 2020-2022 Florian Schmaus
#include <algorithm>
#include <cstdlib> // for abort, exit, EXIT_SUCCESS
#include <iostream> // for operator<<, basic_ostream::o...
......@@ -74,15 +75,17 @@ static void fibKickoff() {
sem.wait();
std::cout << "fib(" << fibNum << ") = " << result << std::endl;
exit(EXIT_SUCCESS);
Runtime::getRuntime()->initiateTermination();
}
auto main(UNUSED_ARG int argc, UNUSED_ARG char* argv[]) -> int {
// const unsigned nthreads = std::thread::hardware_concurrency();
const unsigned nthreads = 2;
const workerid_t defaultWorkerCount = Runtime::getDefaultWorkerCount();
const workerid_t maxWorkerCount = 2;
const workerid_t nthreads = std::min(maxWorkerCount, defaultWorkerCount);
std::cout << "Number of threads: " << nthreads << std::endl;
{
Runtime runtime(nthreads);
Fiber* fibFiber = Fiber::from(&fibKickoff);
......@@ -92,6 +95,7 @@ auto main(UNUSED_ARG int argc, UNUSED_ARG char* argv[]) -> int {
runtime.scheduleFromAnywhere(*fibFiber);
runtime.waitUntilFinished();
}
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment