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 Fischer
emper
Commits
e2266980
Commit
e2266980
authored
3 years ago
by
Florian Schmaus
Browse files
Options
Downloads
Patches
Plain Diff
Move emper::sleep() implemention from header in compilation unit
parent
96d27755
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
emper/Emper.cpp
+17
-1
17 additions, 1 deletion
emper/Emper.cpp
emper/include/emper.hpp
+2
-13
2 additions, 13 deletions
emper/include/emper.hpp
with
19 additions
and
14 deletions
emper/Emper.cpp
+
17
−
1
View file @
e2266980
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright © 2020 Florian Schmaus
// Copyright © 2020
-2021
Florian Schmaus
#include
"Emper.hpp"
#include
<cerrno>
#include
<cstdint>
#include
<stdexcept>
#include
"Common.hpp"
#include
"Runtime.hpp"
#include
"emper-common.h"
#include
"emper-version.h"
#include
"io/Future.hpp"
namespace
emper
{
...
...
@@ -44,4 +48,16 @@ void destroy_runtime() {
delete
runtime
;
}
auto
sleep
(
unsigned
int
seconds
)
->
bool
{
if
constexpr
(
!
emper
::
IO
)
{
DIE_MSG
(
"sleep requires emper::io"
);
}
emper
::
io
::
AlarmFuture
::
Timespec
ts
=
{.
tv_sec
=
seconds
,
.
tv_nsec
=
0
};
emper
::
io
::
AlarmFuture
alarm
(
ts
);
int32_t
res
=
alarm
.
submitAndWait
();
return
res
==
-
ETIME
;
}
}
// namespace emper
This diff is collapsed.
Click to expand it.
emper/include/emper.hpp
+
2
−
13
View file @
e2266980
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright © 2020 Florian Schmaus
// Copyright © 2020
-2021
Florian Schmaus
#pragma once
#include
<cassert>
...
...
@@ -10,7 +10,6 @@
#include
"Fiber.hpp"
#include
"Runtime.hpp"
#include
"SynchronizedFiber.hpp"
#include
"io/Future.hpp"
void
async
(
Fiber
*
fiber
)
{
assert
(
fiber
!=
nullptr
);
...
...
@@ -75,16 +74,6 @@ void yield() {
runtime
->
yield
();
}
auto
sleep
(
unsigned
int
seconds
)
->
bool
{
if
constexpr
(
!
emper
::
IO
)
{
DIE_MSG
(
"sleep requires emper::io"
);
}
emper
::
io
::
AlarmFuture
::
Timespec
ts
=
{.
tv_sec
=
seconds
,
.
tv_nsec
=
0
};
emper
::
io
::
AlarmFuture
alarm
(
ts
);
int32_t
res
=
alarm
.
submitAndWait
();
return
res
==
-
ETIME
;
}
auto
sleep
(
unsigned
int
seconds
)
->
bool
;
}
// namespace emper
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