Kagome
Polkadot Runtime Engine in C++17
kagome::subscription::SubscriptionEngine< EventKey, Receiver, EventParams > Class Template Referencefinal

#include <subscription_engine.hpp>

Inheritance diagram for kagome::subscription::SubscriptionEngine< EventKey, Receiver, EventParams >:
Collaboration diagram for kagome::subscription::SubscriptionEngine< EventKey, Receiver, EventParams >:

Public Types

using EventKeyType = EventKey
 
using ReceiverType = Receiver
 
using SubscriberType = Subscriber< EventKeyType, ReceiverType, EventParams... >
 
using SubscriberWeakPtr = std::weak_ptr< SubscriberType >
 
using SubscribersContainer = std::list< std::pair< SubscriptionSetId, SubscriberWeakPtr >>
 
using IteratorType = typename SubscribersContainer::iterator
 

Public Member Functions

 SubscriptionEngine ()=default
 
 ~SubscriptionEngine ()=default
 
 SubscriptionEngine (SubscriptionEngine &&)=default
 
SubscriptionEngineoperator= (SubscriptionEngine &&)=default
 
 SubscriptionEngine (const SubscriptionEngine &)=delete
 
SubscriptionEngineoperator= (const SubscriptionEngine &)=delete
 
size_t size (const EventKeyType &key) const
 
size_t size () const
 
void notify (const EventKeyType &key, const EventParams &...args)
 

Private Types

using KeyValueContainer = std::unordered_map< EventKeyType, SubscribersContainer >
 

Private Member Functions

IteratorType subscribe (SubscriptionSetId set_id, const EventKeyType &key, SubscriberWeakPtr ptr)
 
void unsubscribe (const EventKeyType &key, const IteratorType &it_remove)
 

Private Attributes

std::shared_mutex subscribers_map_cs_
 
KeyValueContainer subscribers_map_
 

Friends

template<typename KeyType , typename ValueType , typename... Args>
class Subscriber
 

Detailed Description

template<typename EventKey, typename Receiver, typename... EventParams>
class kagome::subscription::SubscriptionEngine< EventKey, Receiver, EventParams >

Template Parameters
EventKey- the type of a specific event from event set (e. g. a key from a storage or a particular kind of event from an enumeration)
Receiver- the type of an object that is a part of a Subscriber internal state and can be accessed on every event
EventParams- set of types of values passed on each event notification

Definition at line 30 of file subscription_engine.hpp.

Member Typedef Documentation

template<typename EventKey , typename Receiver , typename... EventParams>
using kagome::subscription::SubscriptionEngine< EventKey, Receiver, EventParams >::EventKeyType = EventKey

Definition at line 34 of file subscription_engine.hpp.

template<typename EventKey , typename Receiver , typename... EventParams>
using kagome::subscription::SubscriptionEngine< EventKey, Receiver, EventParams >::IteratorType = typename SubscribersContainer::iterator

Definition at line 46 of file subscription_engine.hpp.

template<typename EventKey , typename Receiver , typename... EventParams>
using kagome::subscription::SubscriptionEngine< EventKey, Receiver, EventParams >::KeyValueContainer = std::unordered_map<EventKeyType, SubscribersContainer>
private

Definition at line 62 of file subscription_engine.hpp.

template<typename EventKey , typename Receiver , typename... EventParams>
using kagome::subscription::SubscriptionEngine< EventKey, Receiver, EventParams >::ReceiverType = Receiver

Definition at line 35 of file subscription_engine.hpp.

template<typename EventKey , typename Receiver , typename... EventParams>
using kagome::subscription::SubscriptionEngine< EventKey, Receiver, EventParams >::SubscribersContainer = std::list<std::pair<SubscriptionSetId, SubscriberWeakPtr>>

List is preferable here because this container iterators remain alive after removal from the middle of the container TODO(iceseer): PRE-476 remove processor cache penalty, while iterating, using custom allocator

Definition at line 45 of file subscription_engine.hpp.

template<typename EventKey , typename Receiver , typename... EventParams>
using kagome::subscription::SubscriptionEngine< EventKey, Receiver, EventParams >::SubscriberType = Subscriber<EventKeyType, ReceiverType, EventParams...>

Definition at line 37 of file subscription_engine.hpp.

template<typename EventKey , typename Receiver , typename... EventParams>
using kagome::subscription::SubscriptionEngine< EventKey, Receiver, EventParams >::SubscriberWeakPtr = std::weak_ptr<SubscriberType>

Definition at line 38 of file subscription_engine.hpp.

Constructor & Destructor Documentation

template<typename EventKey , typename Receiver , typename... EventParams>
kagome::subscription::SubscriptionEngine< EventKey, Receiver, EventParams >::SubscriptionEngine ( )
default
template<typename EventKey , typename Receiver , typename... EventParams>
kagome::subscription::SubscriptionEngine< EventKey, Receiver, EventParams >::~SubscriptionEngine ( )
default
template<typename EventKey , typename Receiver , typename... EventParams>
kagome::subscription::SubscriptionEngine< EventKey, Receiver, EventParams >::SubscriptionEngine ( SubscriptionEngine< EventKey, Receiver, EventParams > &&  )
default
template<typename EventKey , typename Receiver , typename... EventParams>
kagome::subscription::SubscriptionEngine< EventKey, Receiver, EventParams >::SubscriptionEngine ( const SubscriptionEngine< EventKey, Receiver, EventParams > &  )
delete

Member Function Documentation

template<typename EventKey , typename Receiver , typename... EventParams>
void kagome::subscription::SubscriptionEngine< EventKey, Receiver, EventParams >::notify ( const EventKeyType key,
const EventParams &...  args 
)
inline

Definition at line 101 of file subscription_engine.hpp.

template<typename EventKey , typename Receiver , typename... EventParams>
SubscriptionEngine& kagome::subscription::SubscriptionEngine< EventKey, Receiver, EventParams >::operator= ( SubscriptionEngine< EventKey, Receiver, EventParams > &&  )
default
template<typename EventKey , typename Receiver , typename... EventParams>
SubscriptionEngine& kagome::subscription::SubscriptionEngine< EventKey, Receiver, EventParams >::operator= ( const SubscriptionEngine< EventKey, Receiver, EventParams > &  )
delete
template<typename EventKey , typename Receiver , typename... EventParams>
size_t kagome::subscription::SubscriptionEngine< EventKey, Receiver, EventParams >::size ( const EventKeyType key) const
inline

Definition at line 86 of file subscription_engine.hpp.

template<typename EventKey , typename Receiver , typename... EventParams>
size_t kagome::subscription::SubscriptionEngine< EventKey, Receiver, EventParams >::size ( ) const
inline

Definition at line 94 of file subscription_engine.hpp.

template<typename EventKey , typename Receiver , typename... EventParams>
IteratorType kagome::subscription::SubscriptionEngine< EventKey, Receiver, EventParams >::subscribe ( SubscriptionSetId  set_id,
const EventKeyType key,
SubscriberWeakPtr  ptr 
)
inlineprivate

Definition at line 67 of file subscription_engine.hpp.

template<typename EventKey , typename Receiver , typename... EventParams>
void kagome::subscription::SubscriptionEngine< EventKey, Receiver, EventParams >::unsubscribe ( const EventKeyType key,
const IteratorType it_remove 
)
inlineprivate

Definition at line 76 of file subscription_engine.hpp.

Friends And Related Function Documentation

template<typename EventKey , typename Receiver , typename... EventParams>
template<typename KeyType , typename ValueType , typename... Args>
friend class Subscriber
friend

Definition at line 60 of file subscription_engine.hpp.

Member Data Documentation

template<typename EventKey , typename Receiver , typename... EventParams>
KeyValueContainer kagome::subscription::SubscriptionEngine< EventKey, Receiver, EventParams >::subscribers_map_
private

Definition at line 65 of file subscription_engine.hpp.

template<typename EventKey , typename Receiver , typename... EventParams>
std::shared_mutex kagome::subscription::SubscriptionEngine< EventKey, Receiver, EventParams >::subscribers_map_cs_
mutableprivate

Definition at line 64 of file subscription_engine.hpp.


The documentation for this class was generated from the following file: