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
Xavier Thompson
typon-concurrency
Commits
679b1887
Commit
679b1887
authored
Aug 09, 2022
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
examples/: Adapt to new exception propagation
parent
b7c7788b
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 @
679b1887
...
@@ -18,51 +18,46 @@ Task<void> hello(int id) {
...
@@ -18,51 +18,46 @@ Task<void> hello(int id) {
co_return
;
co_return
;
}
}
Task
<
void
>
fail
()
{
Task
<
void
>
fail
(
int
delay
)
{
volatile
int
n
=
fibo
(
delay
);
(
void
)
n
;
throw
std
::
exception
();
throw
std
::
exception
();
co_return
;
co_return
;
}
}
Join
<
void
>
fail_join
()
{
Join
<
void
>
fail_join
(
int
delay
=
0
)
{
co_await
fork
(
fail
());
co_await
fork
(
fail
(
delay
));
}
}
Join
<
void
>
join_sync
(
int
max
)
{
Join
<
void
>
join_sync
(
int
max
)
{
for
(
int
id
=
0
;
id
<
max
;
id
++
)
{
for
(
int
id
=
0
;
id
<
max
;
id
++
)
{
co_await
fork
(
hello
(
id
));
co_await
fork
(
hello
(
id
));
}
}
try
{
co_await
fork
(
fail_join
());
co_await
fork
(
fail_join
());
LOG
(
" ... fork(fail_join()) did not throw (stolen continuation)"
);
LOG
(
" ... fork(fail_join()) did not throw (stolen continuation)"
);
}
catch
(
std
::
exception
&
)
{
LOG
(
" ... fork(fail_join()) did throw, rethrowing"
);
throw
;
}
LOG
(
" ... sync()"
);
LOG
(
" ... sync()"
);
try
{
co_await
Sync
();
co_await
Sync
();
LOG
(
" ... ERROR sync() did not throw"
);
LOG
(
" ... ERROR sync() did not throw"
);
}
catch
(
std
::
exception
&
)
{
LOG
(
" ... OK sync() did throw, rethrowing"
);
throw
;
}
}
}
Join
<
void
>
join_no_sync
(
int
max
)
{
Join
<
void
>
join_no_sync
(
int
max
)
{
for
(
int
id
=
0
;
id
<
max
;
id
++
)
{
for
(
int
id
=
0
;
id
<
max
;
id
++
)
{
co_await
fork
(
hello
(
id
));
co_await
fork
(
hello
(
id
));
}
}
try
{
co_await
fork
(
fail_join
());
co_await
fork
(
fail_join
());
LOG
(
" ... fork(fail_join()) did not throw (stolen continuation)"
);
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
);
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
)
{
Root
root_sync
(
int
max
)
{
try
{
try
{
LOG
(
">>> join_sync(%d)"
,
max
);
LOG
(
">>> join_sync(%d)"
,
max
);
...
@@ -83,11 +78,21 @@ Root root_no_sync(int 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
()
{
int
main
()
{
root_sync
(
0
).
call
();
root_sync
(
0
).
call
();
root_sync
(
20
).
call
();
root_sync
(
20
).
call
();
root_no_sync
(
0
).
call
();
root_no_sync
(
0
).
call
();
root_no_sync
(
20
).
call
();
root_no_sync
(
20
).
call
();
root_infinite_fork_loop
().
call
();
puts
(
"done"
);
puts
(
"done"
);
return
0
;
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