Commit 75ee2b5c authored by Xavier Thompson's avatar Xavier Thompson

Adapt test program future.cpp -> promise.cpp

parent b77510b2
......@@ -10,13 +10,13 @@ int fibo(int n) {
return fibo(n - 1) + fibo(n - 2);
}
Task<void> consume(Future<int> & f) {
printf("[%u] waiting on future\n", Scheduler::thread_id);
Task<void> consume(Promise<int> & f) {
printf("[%u] waiting on promise\n", Scheduler::thread_id);
int value = co_await f;
printf("[%u] future yielded %d\n", Scheduler::thread_id, value);
printf("[%u] promise yielded %d\n", Scheduler::thread_id, value);
}
Task<void> produce(Future<int> & f, int n) {
Task<void> produce(Promise<int> & f, int n) {
int value = fibo(n);
printf("[%u] producing %d\n", Scheduler::thread_id, value);
f.put(value);
......@@ -24,7 +24,7 @@ Task<void> produce(Future<int> & f, int n) {
}
Join<void> parallel() {
Future<int> f;
Promise<int> f;
printf("[%u] fork(consume())\n", Scheduler::thread_id);
co_await fork(consume(f));
printf("[%u] fork(produce())\n", Scheduler::thread_id);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment