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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Florian Schmaus
emper
Commits
27ec583d
Commit
27ec583d
authored
Jul 17, 2018
by
Florian Schmaus
Browse files
Options
Downloads
Patches
Plain Diff
Add Rutime::inRuntime() and Runtime::executeAndWait()
parent
b3d17a5b
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
emper/Dispatcher.hpp
+5
-0
5 additions, 0 deletions
emper/Dispatcher.hpp
emper/Runtime.cpp
+22
-0
22 additions, 0 deletions
emper/Runtime.cpp
emper/Runtime.hpp
+4
-0
4 additions, 0 deletions
emper/Runtime.hpp
with
31 additions
and
0 deletions
emper/Dispatcher.hpp
+
5
−
0
View file @
27ec583d
...
...
@@ -56,5 +56,10 @@ public:
return
currentFiber
;
}
static
bool
isDispatchedControlFlow
()
{
const
Fiber
*
fiber
=
getCurrentFiberPtr
();
return
fiber
!=
nullptr
;
}
friend
ContextManager
;
};
This diff is collapsed.
Click to expand it.
emper/Runtime.cpp
+
22
−
0
View file @
27ec583d
...
...
@@ -135,3 +135,25 @@ void Runtime::printLastRuntimeStats() {
currentRuntime
->
printStats
();
}
bool
Runtime
::
inRuntime
()
{
return
dispatcher
.
isDispatchedControlFlow
();
}
void
Runtime
::
executeAndWait
(
std
::
function
<
void
()
>
f
)
{
if
(
inRuntime
())
{
ABORT
(
"Ca not use executeAndWait() from within the Runtime"
);
}
std
::
mutex
fiberFinished
;
fiberFinished
.
lock
();
Fiber
*
fiber
=
Fiber
::
from
([
&
]
{
f
();
fiberFinished
.
unlock
();
});
schedule
(
*
fiber
);
fiberFinished
.
lock
();
}
This diff is collapsed.
Click to expand it.
emper/Runtime.hpp
+
4
−
0
View file @
27ec583d
...
...
@@ -113,6 +113,10 @@ public:
void
printStats
();
bool
inRuntime
();
void
executeAndWait
(
std
::
function
<
void
()
>
f
);
friend
ContextManager
;
friend
Scheduler
;
friend
Dispatcher
;
...
...
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