Skip to main content

fibonacci_waiter_example_task

Function fibonacci_waiter_example_task 

Source
async fn fibonacci_waiter_example_task(
    recv: UnboundedReceiver<(Option<WaitGuard>, usize)>,
    send: UnboundedSender<(Option<WaitGuard>, usize)>,
    incr_count: Sender<()>,
    waiter: Option<WaitGroup>,
)
Expand description

An inefficient Fibonacci implementation. This computes F(n) by sending by n-1 and n-2 back into the channel. This shows how one work item can create multiple subsequent work items.

The result is determined by sending () into an increment channel and reading the number of increments.

This is wildly inefficient because it does not cache any results. Computing F(n) would generate O(2^n) channel items.