Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
typon-concurrency
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
typon
typon-concurrency
Commits
dfbd8f84
Commit
dfbd8f84
authored
1 year ago
by
Tom Niget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add initial support for generators with parameters
parent
960389fb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
4 deletions
+8
-4
rt/include/typon/generator.hpp
rt/include/typon/generator.hpp
+8
-4
No files found.
rt/include/typon/generator.hpp
View file @
dfbd8f84
...
@@ -22,7 +22,7 @@ class Generator
...
@@ -22,7 +22,7 @@ class Generator
Promise
()
=
default
;
Promise
()
=
default
;
std
::
suspend_always
initial_suspend
()
{
return
{};
}
std
::
suspend_always
initial_suspend
()
{
return
{};
}
std
::
suspend_always
final_suspend
()
noexcept
{
return
{};
}
std
::
suspend_always
final_suspend
()
noexcept
{
final
=
true
;
return
{};
}
void
unhandled_exception
()
{
void
unhandled_exception
()
{
std
::
rethrow_exception
(
std
::
move
(
std
::
current_exception
()));
std
::
rethrow_exception
(
std
::
move
(
std
::
current_exception
()));
}
}
...
@@ -47,11 +47,13 @@ class Generator
...
@@ -47,11 +47,13 @@ class Generator
}
}
bool
finished
()
{
bool
finished
()
{
return
!
value
.
has_value
();
//return !value.has_value();
return
final
;
}
}
private:
private:
value_type
value
{};
value_type
value
{};
bool
final
=
false
;
};
};
public:
public:
...
@@ -68,7 +70,9 @@ public:
...
@@ -68,7 +70,9 @@ public:
Promise
::
value_type
next
()
{
Promise
::
value_type
next
()
{
if
(
handle
)
{
if
(
handle
)
{
handle
.
resume
();
if
(
!
handle
.
promise
().
finished
())
{
handle
.
resume
();
}
return
handle
.
promise
().
get_value
();
return
handle
.
promise
().
get_value
();
}
}
else
{
else
{
...
@@ -135,7 +139,7 @@ public:
...
@@ -135,7 +139,7 @@ public:
}
}
std
::
optional
<
value_type
>
py_next
()
{
std
::
optional
<
value_type
>
py_next
()
{
return
*
begin
();
return
next
();
}
}
private:
private:
...
...
This diff is collapsed.
Click to expand it.
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