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
75ee2b5c
Commit
75ee2b5c
authored
Jun 22, 2022
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adapt test program future.cpp -> promise.cpp
parent
b77510b2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
rt/test/promise.cpp
rt/test/promise.cpp
+5
-5
No files found.
rt/test/
futur
e.cpp
→
rt/test/
promis
e.cpp
View file @
75ee2b5c
...
@@ -10,13 +10,13 @@ int fibo(int n) {
...
@@ -10,13 +10,13 @@ int fibo(int n) {
return
fibo
(
n
-
1
)
+
fibo
(
n
-
2
);
return
fibo
(
n
-
1
)
+
fibo
(
n
-
2
);
}
}
Task
<
void
>
consume
(
Futur
e
<
int
>
&
f
)
{
Task
<
void
>
consume
(
Promis
e
<
int
>
&
f
)
{
printf
(
"[%u] waiting on
futur
e
\n
"
,
Scheduler
::
thread_id
);
printf
(
"[%u] waiting on
promis
e
\n
"
,
Scheduler
::
thread_id
);
int
value
=
co_await
f
;
int
value
=
co_await
f
;
printf
(
"[%u]
futur
e yielded %d
\n
"
,
Scheduler
::
thread_id
,
value
);
printf
(
"[%u]
promis
e yielded %d
\n
"
,
Scheduler
::
thread_id
,
value
);
}
}
Task
<
void
>
produce
(
Futur
e
<
int
>
&
f
,
int
n
)
{
Task
<
void
>
produce
(
Promis
e
<
int
>
&
f
,
int
n
)
{
int
value
=
fibo
(
n
);
int
value
=
fibo
(
n
);
printf
(
"[%u] producing %d
\n
"
,
Scheduler
::
thread_id
,
value
);
printf
(
"[%u] producing %d
\n
"
,
Scheduler
::
thread_id
,
value
);
f
.
put
(
value
);
f
.
put
(
value
);
...
@@ -24,7 +24,7 @@ Task<void> produce(Future<int> & f, int n) {
...
@@ -24,7 +24,7 @@ Task<void> produce(Future<int> & f, int n) {
}
}
Join
<
void
>
parallel
()
{
Join
<
void
>
parallel
()
{
Futur
e
<
int
>
f
;
Promis
e
<
int
>
f
;
printf
(
"[%u] fork(consume())
\n
"
,
Scheduler
::
thread_id
);
printf
(
"[%u] fork(consume())
\n
"
,
Scheduler
::
thread_id
);
co_await
fork
(
consume
(
f
));
co_await
fork
(
consume
(
f
));
printf
(
"[%u] fork(produce())
\n
"
,
Scheduler
::
thread_id
);
printf
(
"[%u] fork(produce())
\n
"
,
Scheduler
::
thread_id
);
...
...
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