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
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
cython-plus
typon
Commits
df650572
Commit
df650572
authored
Aug 09, 2022
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
examples/: Adapt to new exception propagation
parent
0e135934
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
25 deletions
+30
-25
rt/examples/fork_exceptions.cpp
rt/examples/fork_exceptions.cpp
+30
-25
No files found.
rt/examples/fork_exceptions.cpp
View file @
df650572
...
...
@@ -18,51 +18,46 @@ Task<void> hello(int id) {
co_return
;
}
Task
<
void
>
fail
()
{
Task
<
void
>
fail
(
int
delay
)
{
volatile
int
n
=
fibo
(
delay
);
(
void
)
n
;
throw
std
::
exception
();
co_return
;
}
Join
<
void
>
fail_join
()
{
co_await
fork
(
fail
());
Join
<
void
>
fail_join
(
int
delay
=
0
)
{
co_await
fork
(
fail
(
delay
));
}
Join
<
void
>
join_sync
(
int
max
)
{
for
(
int
id
=
0
;
id
<
max
;
id
++
)
{
co_await
fork
(
hello
(
id
));
}
try
{
co_await
fork
(
fail_join
());
LOG
(
" ... fork(fail_join()) did not throw (stolen continuation)"
);
}
catch
(
std
::
exception
&
)
{
LOG
(
" ... fork(fail_join()) did throw, rethrowing"
);
throw
;
}
LOG
(
" ... sync()"
);
try
{
co_await
Sync
();
LOG
(
" ... ERROR sync() did not throw"
);
}
catch
(
std
::
exception
&
)
{
LOG
(
" ... OK sync() did throw, rethrowing"
);
throw
;
}
}
Join
<
void
>
join_no_sync
(
int
max
)
{
for
(
int
id
=
0
;
id
<
max
;
id
++
)
{
co_await
fork
(
hello
(
id
));
}
try
{
co_await
fork
(
fail_join
());
LOG
(
" ... fork(fail_join()) did not throw (stolen continuation)"
);
}
catch
(
std
::
exception
&
)
{
LOG
(
" ... fork(fail_join()) did throw, rethrowing"
);
throw
;
}
LOG
(
" ... join_no_sync(%d) is exiting normally"
,
max
);
}
Join
<
void
>
join_infinite_fork_loop
()
{
co_await
fork
(
fail_join
(
25
));
LOG
(
" ... fork(fail_join()) did not throw (stolen continuation)"
);
LOG
(
" ... now looping forever"
);
for
(
int
id
=
0
;
;
id
++
)
{
co_await
fork
(
hello
(
id
));
}
}
Root
root_sync
(
int
max
)
{
try
{
LOG
(
">>> join_sync(%d)"
,
max
);
...
...
@@ -83,11 +78,21 @@ Root root_no_sync(int max) {
}
}
Root
root_infinite_fork_loop
()
{
try
{
LOG
(
">>> join_infinite_fork_loop()"
);
co_await
join_infinite_fork_loop
();
}
catch
(
std
::
exception
&
)
{
LOG
(
"OK join_infinite_fork_loop() did throw eventually
\n
"
);
}
}
int
main
()
{
root_sync
(
0
).
call
();
root_sync
(
20
).
call
();
root_no_sync
(
0
).
call
();
root_no_sync
(
20
).
call
();
root_infinite_fork_loop
().
call
();
puts
(
"done"
);
return
0
;
}
...
...
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