Notes on Erik Nieblers talk https://www.youtube.com/watch?v=xiaqNvqRB2E code: https://godbolt.org/z/dnrabsbdq
auto thenSender = then(just(42), [](int i) { return i + 1; });
auto thenOeration = connect(thenSender, cout_receiver{});
start(thenOperation);
The call stack goes
- then_operation::start
- just_operation::start
- then_receiver::set_value
- cout_receiver::set_value
So the structures must be nested as follows
then_operation { just_operation { then_receiver { cout_receiver {} } }
To do this first we must nest the senders
then_sender { just_sender {} }
then connect propogates down these nested senders. The first call to connect (then_sender::connect
) places it's receiver parameter (cout_receiver
) into a receiver (then_receiver
) corresponding to the sender (then_sender
)
A = then_receiver { cout_receiver }
but also the recursive conncet calls build up
B = then_operation { just_operation {...} }
The last connect (just_sender::connect
) then nests these two nested structures connect has built
A { B } = then_operation { just_operation { then_receiver { cout_receiver {} } }