Пример #1
0
 virtual worker create_worker(composite_subscription cs) const {
     // use different lifetime
     auto inner_lifetime = controller.get_subscription();
     auto token = inner_lifetime.add(cs);
     cs.add([inner_lifetime, token](){inner_lifetime.remove(token);});
     return worker(cs, controller);
 }
Пример #2
0
    void on_connect(composite_subscription cs) {
        if (connection.empty()) {
            // the lifetime of each connect is independent
            auto destination = subject_value.get_subscriber();

            // when the paramter is unsubscribed it should
            // unsubscribe the most recent connection
            connection.reset(cs.add(destination.get_subscription()));

            // when the connection is finished it should shutdown the connection
            destination.add(make_subscription(
                [cs, this](){
                    cs.remove(this->connection.get());
                    this->connection.reset();
                }));

            source.subscribe(destination);
        }
    }
Пример #3
0
 weak_subscription add(subscription s) const {
     return lifetime.add(std::move(s));
 }