// // Copyright (c) ZeroC, Inc. All rights reserved. // #ifndef OBSERVERS_H #define OBSERVERS_H #include #include #include #include namespace IceStorm { class TraceLevels; } namespace IceStormElection { class Observers { public: Observers(std::shared_ptr); void setMajority(unsigned int); // Check that we have enough nodes for replication. bool check(); void clear(); void init(const std::set&, const LogUpdate&, const TopicContentSeq&); void createTopic(const LogUpdate&, const std::string&); void destroyTopic(const LogUpdate&, const std::string&); void addSubscriber(const LogUpdate&, const std::string&, const IceStorm::SubscriberRecord&); void removeSubscriber(const LogUpdate&, const std::string&, const Ice::IdentitySeq&); void getReapedSlaves(std::vector&); private: void wait(const std::string&); const std::shared_ptr _traceLevels; unsigned int _majority; struct ObserverInfo { int id; std::shared_ptr observer; std::future future; }; std::vector _observers; std::mutex _reapedMutex; std::vector _reaped; std::mutex _mutex; }; } #endif // OBSERVERS_H