Guest User

Untitled

a guest
Jan 27th, 2020
74
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Aggregator::Aggregator(){}
  2.  
  3. const RequestObjectPtr Aggregator::add_aggregat(MessagePtr message)
  4. {
  5.     std::scoped_lock lk(mutex_);
  6.     //for every aggregat
  7.     for(auto aggregat = aggregats_.begin();
  8.              aggregat != aggregats_.end();
  9.              aggregat++){
  10.  
  11.         //skip if the message doesnt match the aggregat
  12.         if(not aggregat->add_message(message)){
  13.             continue;
  14.         }
  15.  
  16.         //if complete return result message and erase aggregat
  17.         if(aggregat->is_complete()){
  18.             auto result = aggregat->get_result_message();
  19.             aggregats_.erase(aggregat);
  20.             return result;
  21.         }
  22.         break;
  23.     }
  24.     return nullptr;
  25. }
  26.  
  27. void Aggregator::add_aggregat(RequestObjectPtr request, std::unordered_set<std::string> ids)
  28. {
  29.     std::scoped_lock lk(mutex_);
  30.     aggregats_.push_back(Aggregat(request, ids));
  31. }
RAW Paste Data