Skip to content

repeat_effect_until with a once called initialisation #1434

Answered by maikel
mathisloge asked this question in Q&A
Discussion options

You must be logged in to vote

Try let_value. If your context type is move-constructible then this will be good enough. Otherwise, you need some helper senders.

Take care when using exec::repeat_effect_until with the pipe operator. It can be surprising what will be repeated.

#include <stdexec/execution.hpp>
#include <exec/single_thread_context.hpp>
#include <exec/repeat_effect_until.hpp>

#include <print>

class MyContext {
public:
    explicit MyContext(int data): data_{data} {}

    auto receiveMessage() {
        return stdexec::just(data_);
    }

private:
    int data_;
};

int main()
{
    exec::single_thread_context context;
    auto scheduler = context.get_scheduler();

    auto sndr = //
        stdexec::when_all

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mathisloge
Comment options

Answer selected by mathisloge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants