Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
emper
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Florian Schmaus
emper
Commits
f751adac
Commit
f751adac
authored
3 years ago
by
Florian Schmaus
Browse files
Options
Downloads
Patches
Plain Diff
[SimplestFibTest] Run Runtime destructor and allow worker count reduction
parent
f9891762
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/SimplestFibTest.cpp
+13
-9
13 additions, 9 deletions
tests/SimplestFibTest.cpp
with
13 additions
and
9 deletions
tests/SimplestFibTest.cpp
+
13
−
9
View file @
f751adac
// 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
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment