Esempio n. 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);
 }
Esempio n. 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);
        }
    }
Esempio n. 3
0
 void unsubscribe() const {
     return lifetime.unsubscribe();
 }
Esempio n. 4
0
 void clear() const {
     return lifetime.clear();
 }
Esempio n. 5
0
 void remove(weak_subscription w) const {
     return lifetime.remove(std::move(w));
 }
Esempio n. 6
0
 weak_subscription add(subscription s) const {
     return lifetime.add(std::move(s));
 }
Esempio n. 7
0
 // composite_subscription
 //
 bool is_subscribed() const {
     return lifetime.is_subscribed();
 }