Shows basic usage of the FRI-OS wrapped POSIX threads
#include <iostream>
#include <cstdlib>
struct computation
{
int argument;
unsigned long long result;
};
unsigned long long fib(int n)
{
if(n < 2) return 1;
else return fib(n-2) + fib(n-1);
}
void* calc_fib(void* raw_ptr)
{
computation* c = static_cast<computation*>(raw_ptr);
c->result = fib(c->argument);
return nullptr;
}
int main(int argc, const char* argv[])
{
int arg = (argc>1)?std::atoi(argv[1]):42;
if(arg <= 0) arg = 42;
computation comp = {arg, 0};
worker.wait_for();
std::cout << "fib(" << comp.argument << ") = " << comp.result << std::endl;
return 0;
}