Exemple #1
0
 void on_error(std::exception_ptr e) const {
     if (!is_subscribed()) {
         return;
     }
     detacher protect(this);
     destination.on_error(e);
 }
Exemple #2
0
 void add(const SubscriberFrom& sf, observer_type o) const {
     trace_activity().connect(sf, o);
     std::unique_lock<std::mutex> guard(b->state->lock);
     switch (b->state->current) {
     case mode::Casting:
         {
             if (o.is_subscribed()) {
                 b->completer = std::make_shared<completer_type>(b->state, b->completer, o);
                 ++b->state->generation;
             }
         }
         break;
     case mode::Completed:
         {
             guard.unlock();
             o.on_completed();
             return;
         }
         break;
     case mode::Errored:
         {
             auto e = b->state->error;
             guard.unlock();
             o.on_error(e);
             return;
         }
         break;
     default:
         abort();
     }
 }
Exemple #3
0
 void add(const SubscriberFrom& sf, observer_type o) const {
     trace_activity().connect(sf, o);
     std::unique_lock<std::mutex> guard(b->state->lock);
     switch (b->state->current) {
     case mode::Casting:
         {
             if (o.is_subscribed()) {
                 std::weak_ptr<binder_type> binder = b;
                 o.add([=](){
                     auto b = binder.lock();
                     if (b) {
                         std::unique_lock<std::mutex> guard(b->state->lock);
                         b->completer = std::make_shared<completer_type>(b->state, b->completer);
                     }
                 });
                 b->completer = std::make_shared<completer_type>(b->state, b->completer, o);
             }
         }
         break;
     case mode::Completed:
         {
             guard.unlock();
             o.on_completed();
             return;
         }
         break;
     case mode::Errored:
         {
             auto e = b->state->error;
             guard.unlock();
             o.on_error(e);
             return;
         }
         break;
     case mode::Disposed:
         {
             guard.unlock();
             o.unsubscribe();
             return;
         }
         break;
     default:
         std::terminate();
     }
 }