Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
typon
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tom Niget
typon
Commits
edbbe69a
Commit
edbbe69a
authored
Aug 08, 2022
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Drop policy to optimize void / ignored results
parent
70dca6f1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
23 deletions
+33
-23
rt/include/typon/fork.hpp
rt/include/typon/fork.hpp
+33
-1
rt/include/typon/forked.hpp
rt/include/typon/forked.hpp
+0
-22
No files found.
rt/include/typon/fork.hpp
View file @
edbbe69a
...
@@ -79,13 +79,45 @@ namespace typon
...
@@ -79,13 +79,45 @@ namespace typon
};
};
};
};
struct
Drop
{
void
on_final_suspend
(
std
::
coroutine_handle
<>
coroutine
)
noexcept
{
coroutine
.
destroy
();
}
struct
OnAwaitable
{
Span
*
_span
;
Span
::
u64
_rank
;
template
<
typename
Promise
>
void
on_await_suspend
(
std
::
coroutine_handle
<
Promise
>
coroutine
)
noexcept
{
_span
=
coroutine
.
promise
().
_span
;
_rank
=
_span
->
_thefts
;
}
template
<
typename
Promise
>
void
on_await_resume
(
std
::
coroutine_handle
<
Promise
>
coroutine
)
{
if
(
_span
->
_thefts
==
_rank
)
{
Defer
defer
{
[
coroutine
]()
{
coroutine
.
destroy
();
}
};
coroutine
.
promise
().
get
();
}
}
};
};
}
}
template
<
typename
T
=
void
,
typename
P
olicy
=
policy
::
Refcnt
>
template
<
typename
T
=
void
,
typename
P
=
policy
::
Refcnt
>
struct
[[
nodiscard
]]
Fork
struct
[[
nodiscard
]]
Fork
{
{
struct
promise_type
;
struct
promise_type
;
using
u64
=
Span
::
u64
;
using
u64
=
Span
::
u64
;
using
Policy
=
std
::
conditional_t
<
std
::
is_same_v
<
T
,
void
>
,
policy
::
Drop
,
P
>
;
std
::
coroutine_handle
<
promise_type
>
_coroutine
;
std
::
coroutine_handle
<
promise_type
>
_coroutine
;
...
...
rt/include/typon/forked.hpp
View file @
edbbe69a
...
@@ -89,28 +89,6 @@ namespace typon
...
@@ -89,28 +89,6 @@ namespace typon
};
};
template
<
>
struct
ForkResult
<
void
>
{
ForkNode
*
_node
{
nullptr
};
template
<
typename
Promise
>
void
construct_value
(
std
::
coroutine_handle
<
Promise
>
coroutine
)
{
coroutine
.
promise
().
get
();
}
void
construct_value
(
ForkResult
&&
other
)
noexcept
{
(
void
)
other
;
}
void
get_value
()
noexcept
{}
void
destroy_value
()
noexcept
{}
};
template
<
typename
T
>
template
<
typename
T
>
struct
Forked
:
ForkResult
<
T
>
struct
Forked
:
ForkResult
<
T
>
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment