Commit a45fcb61 authored by Xavier Thompson's avatar Xavier Thompson

Remove forkjoin.cpp

parent 35bcc206
#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<void> hello(int i) {
int n = fibo(10);
(void) i;
(void) n;
printf("hello from %d on %u, fibo(40) = %d\n", i, Scheduler::thread_id, n);
// printf("hello from %d on %lu, fibo(40) = %d\n", i, riften::detail::static_id, n);
co_return;
}
Join<void> parallel() {
for (int i = 0; i < 30; i++) {
co_await fork(hello(i));
printf("parallel resumed on %u\n", Scheduler::thread_id);
// printf("parallel resumed on %lu\n", riften::detail::static_id);
}
printf("parallel syncing on %u\n", Scheduler::thread_id);
// printf("parallel syncing on %lu\n", riften::detail::static_id);
co_await Sync();
printf("parallel resumed on %u\n", Scheduler::thread_id);
// printf("parallel resumed on %lu\n", riften::detail::static_id);
for (int i = 30; i < 60; i++) {
co_await fork(hello(i));
printf("parallel resumed on %u\n", Scheduler::thread_id);
// printf("parallel resumed on %lu\n", riften::detail::static_id);
}
}
Root root() {
co_await parallel();
printf("root resumed on %u\n", Scheduler::thread_id);
}
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