Commit 1d137d44 authored by Xavier Thompson's avatar Xavier Thompson

Add test program leaked_future.cpp

parent 46e17962
#include <typon/typon.hpp>
#include <cstdio>
using namespace typon;
int fibo(int n) {
if (n < 2)
return n;
return fibo(n - 1) + fibo(n - 2);
}
Task<int> producer(int n) {
int value = fibo(n);
printf("[%u] producing %d\n", Scheduler::thread_id, value);
co_return value;
}
Task<void> consumer() {
printf("[%u] launching future\n", Scheduler::thread_id);
Future f = co_await future(producer(40));
printf("[%u] leaking future\n", Scheduler::thread_id);
}
Root root() {
co_await consumer();
}
int main() {
root().call();
puts("done");
return 0;
}
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