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
d8a6ade9
Commit
d8a6ade9
authored
3 years ago
by
Florian Fischer
Browse files
Options
Downloads
Patches
Plain Diff
[Future] remove not used rvalue reference setCallback
parent
388bd882
No related branches found
No related tags found
No related merge requests found
Pipeline
#61849
passed
3 years ago
Stage: smoke-test
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
emper/io/Future.hpp
+5
-23
5 additions, 23 deletions
emper/io/Future.hpp
tests/io/FutureCallbackTest.cpp
+4
-6
4 additions, 6 deletions
tests/io/FutureCallbackTest.cpp
with
9 additions
and
29 deletions
emper/io/Future.hpp
+
5
−
23
View file @
d8a6ade9
...
...
@@ -56,10 +56,7 @@ class Future : public Logger<LogSubsystem::IO> {
public:
workeraffinity_t
affinity
;
// store callback via copy
CallbackInternal
(
Callback
callback
)
:
callback
(
std
::
move
(
callback
))
{}
// store callback via move
CallbackInternal
(
const
Callback
&&
callback
)
:
callback
(
callback
)
{}
void
operator
()(
const
int32_t
&
res
)
{
callback
(
res
);
}
};
...
...
@@ -247,32 +244,17 @@ class Future : public Logger<LogSubsystem::IO> {
this
->
dependency
=
&
dependency
;
}
private
:
inline
void
setCallback
(
CallbackInternal
*
callback
)
{
if
(
unlikely
(
this
->
callback
))
{
delete
this
->
callback
;
}
this
->
callback
=
callback
;
}
public
:
/*
* @brief register a callback which is executed in a new Fiber on completion
*
* @param callback Callback reference which is copied and executed on completion.
* It gets passed the value causing the completion.
*/
inline
void
setCallback
(
const
Callback
&
callback
)
{
setCallback
(
new
CallbackInternal
(
callback
));
}
/*
* @brief register a callback which is executed in a new Fiber on completion
*
* @param callback Callback rvalue which gets moved and executed on completion.
* It gets passed the value causing the completion.
*/
inline
void
setCallback
(
const
Callback
&&
callback
)
{
setCallback
(
new
CallbackInternal
(
callback
));
inline
void
setCallback
(
const
Callback
&
callback
)
{
if
(
unlikely
(
this
->
callback
))
{
delete
this
->
callback
;
}
this
->
callback
=
new
CallbackInternal
(
callback
);
}
/*
...
...
This diff is collapsed.
Click to expand it.
tests/io/FutureCallbackTest.cpp
+
4
−
6
View file @
d8a6ade9
...
...
@@ -10,17 +10,15 @@
using
emper
::
io
::
AlarmFuture
;
using
emper
::
io
::
Future
;
void
callback
(
int32_t
res
,
BPS
&
bps
)
{
assert
(
res
==
-
ETIME
);
bps
.
signal
();
}
void
emperTest
()
{
AlarmFuture
::
Timespec
ts
=
{.
tv_sec
=
1
,
.
tv_nsec
=
0
};
AlarmFuture
alarm
(
ts
);
BPS
bps
;
alarm
.
setCallback
(
Future
::
Callback
([
&
bps
](
int32_t
res
)
{
callback
(
res
,
bps
);
}));
alarm
.
setCallback
([
&
bps
](
int32_t
res
)
{
assert
(
res
==
-
ETIME
);
bps
.
signal
();
});
alarm
.
submit
();
// wait till the callback was executed
...
...
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