MCPcopy Create free account
hub / github.com/bloomberg/quantum / recursive_fib

Function recursive_fib

tests/quantum_tests.cpp:201–216  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199}
200
201int recursive_fib(CoroContext<size_t>::Ptr ctx, size_t fib)
202{
203 ctx->sleep(us(100));
204
205 if (fib <= 2)
206 {
207 return ctx->set(1);
208 }
209 else
210 {
211 //Post both branches of the Fibonacci series before blocking on get().
212 auto ctx1 = ctx->post(recursive_fib, fib - 2);
213 auto ctx2 = ctx->post(recursive_fib, fib - 1);
214 return ctx->set(ctx1->get(ctx) + ctx2->get(ctx));
215 }
216}
217
218void run_coro(Traits::Coroutine& coro, std::mutex& m, int& end, int start)
219{

Callers

nothing calls this directly

Calls 4

sleepMethod · 0.45
setMethod · 0.45
postMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected