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
86c22b37
Commit
86c22b37
authored
3 years ago
by
Florian Schmaus
Browse files
Options
Downloads
Patches
Plain Diff
[IoContext] Add castIfIoFuture() helper function
parent
75d444d3
Branches
cast-if-future
No related tags found
No related merge requests found
Pipeline
#57433
passed
3 years ago
Stage: smoke-test
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
emper/io/IoContext.cpp
+11
-5
11 additions, 5 deletions
emper/io/IoContext.cpp
with
11 additions
and
5 deletions
emper/io/IoContext.cpp
+
11
−
5
View file @
86c22b37
...
...
@@ -31,13 +31,20 @@
static
const
uintptr_t
IOCONTEXT_TAG
=
1L
<<
(
sizeof
(
size_t
)
*
8
-
1
);
static
const
uintptr_t
IOCONTEXT_TAG_MASK
=
IOCONTEXT_TAG
-
1
;
static
inline
auto
isIoContext
(
uintptr_t
ptr
)
->
bool
{
return
(
ptr
&
IOCONTEXT_TAG
)
!=
0
;
}
namespace
emper
::
io
{
static
inline
auto
castIfIoFuture
(
uintptr_t
ptr
)
->
Future
*
{
if
(
ptr
&
IOCONTEXT_TAG
)
{
return
nullptr
;
}
return
reinterpret_cast
<
Future
*>
(
ptr
);
}
static
inline
auto
stripIoContextTag
(
uintptr_t
ptr
)
->
IoContext
*
{
return
reinterpret_cast
<
IoContext
*>
(
ptr
&
IOCONTEXT_TAG_MASK
);
}
namespace
emper
::
io
{
thread_local
IoContext
*
IoContext
::
workerIo
=
nullptr
;
pthread_t
IoContext
::
globalCompleter
;
...
...
@@ -258,9 +265,8 @@ auto IoContext::globalCompleterFunc(void *arg) -> void * {
auto
data
=
(
uintptr_t
)
io_uring_cqe_get_data
(
cqe
);
// The cqe is for a completed Future
if
(
unlikely
(
!
isIoContext
(
data
)))
{
auto
*
future
=
reinterpret_cast
<
Future
*>
(
data
);
auto
*
future
=
castIfIoFuture
(
data
);
if
(
unlikely
(
future
))
{
uint32_t
res
=
cqe
->
res
;
io_uring_cqe_seen
(
&
io
.
ring
,
cqe
);
...
...
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