#include <Event_Map_T.h>
Collaboration diagram for TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >:
Public Types | |
typedef TAO_Notify_Event_Map_Entry_T< PROXY > | ENTRY |
Public Member Functions | |
TAO_Notify_Event_Map_T (void) | |
Constructor. | |
~TAO_Notify_Event_Map_T () | |
Destructor. | |
void | init (void) |
Init. | |
void | connect (PROXY *proxy) |
Connect a PROXY. | |
void | disconnect (PROXY *proxy) |
Disconnect a PROXY. | |
int | insert (PROXY *proxy, const TAO_Notify_EventType &event_type) |
int | remove (PROXY *proxy, const TAO_Notify_EventType &event_type) |
ENTRY * | find (const TAO_Notify_EventType &event_type) |
ENTRY::COLLECTION * | broadcast_collection (void) |
Find the default broadcast list. | |
ENTRY::COLLECTION * | updates_collection (void) |
Find the update list. This is all the PROXYS connected to this Map. | |
void | release (ENTRY *entry) |
Release the usage count on this entry. | |
const TAO_Notify_EventTypeSeq & | event_types (void) |
Access all the event types available. | |
int | proxy_count (void) |
Access number of proxys connected in all. | |
Protected Attributes | |
ACE_Hash_Map_Manager< TAO_Notify_EventType, ENTRY *, ACE_SYNCH_NULL_MUTEX > | map_ |
The Map that stores eventtype to entry mapping. | |
ACE_LOCK | lock_ |
The lock to use. | |
int | proxy_count_ |
Count of proxys connected. | |
ENTRY | broadcast_entry_ |
The default broadcast list for EventType::special. | |
ENTRY | updates_entry_ |
Update Entry - Keeps a list of all PROXY's connected to this Map. Updates are send to this list. | |
TAO_Notify_EventTypeSeq | event_types_ |
The event types that are available in this map. |
Definition at line 38 of file Event_Map_T.h.
typedef TAO_Notify_Event_Map_Entry_T<PROXY> TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::ENTRY |
Definition at line 42 of file Event_Map_T.h.
TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::TAO_Notify_Event_Map_T | ( | void | ) |
Constructor.
Definition at line 19 of file Event_Map_T.cpp.
00020 :proxy_count_ (0) 00021 { 00022 00023 }
TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::~TAO_Notify_Event_Map_T | ( | ) |
ACE_INLINE TAO_Notify_Event_Map_Entry_T< PROXY >::COLLECTION * TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::broadcast_collection | ( | void | ) |
Find the default broadcast list.
Definition at line 54 of file Event_Map_T.inl.
References TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::broadcast_entry_, and TAO_Notify_Event_Map_Entry_T< PROXY >::collection().
00055 { 00056 return this->broadcast_entry_.collection (); 00057 }
void TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::connect | ( | PROXY * | proxy | ) |
Connect a PROXY.
Definition at line 39 of file Event_Map_T.cpp.
References ACE_WRITE_GUARD, TAO_Notify_Event_Map_Entry_T< PROXY >::connected(), TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::proxy_count_, and TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::updates_entry_.
Referenced by TAO_Notify_Event_Manager::connect().
00040 { 00041 this->updates_entry_.connected (proxy); 00042 00043 ACE_WRITE_GUARD (ACE_LOCK, ace_mon, this->lock_); 00044 ++this->proxy_count_; 00045 }
void TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::disconnect | ( | PROXY * | proxy | ) |
Disconnect a PROXY.
Definition at line 48 of file Event_Map_T.cpp.
References ACE_WRITE_GUARD, TAO_Notify_Event_Map_Entry_T< PROXY >::disconnected(), TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::proxy_count_, and TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::updates_entry_.
Referenced by TAO_Notify_Event_Manager::disconnect().
00049 { 00050 this->updates_entry_.disconnected (proxy); 00051 00052 ACE_WRITE_GUARD (ACE_LOCK, ace_mon, this->lock_); 00053 --this->proxy_count_; 00054 }
ACE_INLINE const TAO_Notify_EventTypeSeq & TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::event_types | ( | void | ) |
Access all the event types available.
Definition at line 72 of file Event_Map_T.inl.
References TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::event_types_.
00073 { 00074 return this->event_types_; 00075 }
TAO_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE TAO_Notify_Event_Map_Entry_T< PROXY > * TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::find | ( | const TAO_Notify_EventType & | event_type | ) |
Find the collection mapped to the <event_type> The usage_count on the entry returned is incremented.
Definition at line 8 of file Event_Map_T.inl.
References TAO_Notify_Event_Map_Entry_T< PROXY >::_incr_refcnt(), ACE_READ_GUARD_RETURN, ACE_SYNCH_NULL_MUTEX, and TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::map_.
00009 { 00010 TAO_Notify_Event_Map_Entry_T<PROXY>* entry = 0; 00011 00012 ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, 0); 00013 00014 if (map_.find (event_type, entry) == 0) 00015 { 00016 entry->_incr_refcnt (); 00017 return entry; 00018 } 00019 else 00020 { 00021 // The event_type that we have doesn't hash directly to a particular 00022 // entry. So, we need to iterate through the map and see if any of 00023 // the event type keys are equivalent to event_type. 00024 typedef ACE_Hash_Map_Iterator_Ex <TAO_Notify_EventType, ENTRY*, 00025 ACE_Hash<TAO_Notify_EventType>, 00026 ACE_Equal_To<TAO_Notify_EventType>, 00027 ACE_SYNCH_NULL_MUTEX> 00028 Iterator_Type; 00029 Iterator_Type end = this->map_.end (); 00030 for(Iterator_Type i = this->map_.begin (); i != end; ++i) 00031 { 00032 if ((*i).ext_id_ == event_type) 00033 { 00034 entry = (*i).int_id_; 00035 entry->_incr_refcnt (); 00036 return entry; 00037 } 00038 } 00039 } 00040 00041 return 0; 00042 }
void TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::init | ( | void | ) |
Init.
Definition at line 31 of file Event_Map_T.cpp.
References TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::broadcast_entry_, TAO_Notify_Event_Map_Entry_T< PROXY >::init(), and TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::updates_entry_.
00032 { 00033 this->broadcast_entry_.init (); 00034 00035 this->updates_entry_.init (); 00036 }
int TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::insert | ( | PROXY * | proxy, | |
const TAO_Notify_EventType & | event_type | |||
) |
Associate PROXY and event_type. Returns 1 if <event_type> is being seem for the 1st time otherwise returns 0. Returns -1 on error.
Definition at line 57 of file Event_Map_T.cpp.
References ACE_NEW_THROW_EX, ACE_READ_GUARD_RETURN, ACE_WRITE_GUARD_RETURN, TAO_Notify_Event_Map_Entry_T< PROXY >::connected(), TAO_Notify_Event_Map_Entry_T< PROXY >::init(), TAO_Notify_EventType::is_special(), and TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::map_.
Referenced by TAO_Notify_Event_Manager::publish().
00058 { 00059 ENTRY* entry; 00060 00061 int result = -1; 00062 00063 if (event_type.is_special () == 1) 00064 { 00065 entry = &this->broadcast_entry_; 00066 00067 result = 0; 00068 } 00069 else 00070 { 00071 ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); 00072 00073 result = this->map_.find (event_type, entry); 00074 } 00075 00076 if (result == -1) // This type is being seen for the first time. 00077 { 00078 ACE_NEW_THROW_EX (entry, 00079 ENTRY (), 00080 CORBA::NO_MEMORY ()); 00081 00082 entry->init (); 00083 00084 entry->connected (proxy); 00085 00086 ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); 00087 00088 if (map_.bind (event_type, entry) == -1) 00089 throw CORBA::NO_MEMORY (); 00090 00091 if (this->event_types_.insert (event_type) == -1) 00092 return -1; 00093 00094 return 1; 00095 } 00096 else // Add to existing entry or the broadcast entry. 00097 { 00098 entry->connected (proxy); 00099 } 00100 00101 return 0; 00102 }
ACE_INLINE int TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::proxy_count | ( | void | ) |
Access number of proxys connected in all.
Definition at line 66 of file Event_Map_T.inl.
References TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::proxy_count_.
Referenced by TAO_Notify_Event_Manager::~TAO_Notify_Event_Manager().
00067 { 00068 return this->proxy_count_; 00069 }
ACE_INLINE void TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::release | ( | ENTRY * | entry | ) |
Release the usage count on this entry.
Definition at line 45 of file Event_Map_T.inl.
References TAO_Notify_Event_Map_Entry_T< PROXY >::_decr_refcnt(), and ACE_WRITE_GUARD.
00046 { 00047 ACE_WRITE_GUARD (ACE_LOCK, ace_mon, this->lock_); 00048 00049 if (entry->_decr_refcnt () == 0) 00050 delete entry; 00051 }
int TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::remove | ( | PROXY * | proxy, | |
const TAO_Notify_EventType & | event_type | |||
) |
Remove association of PROXY and event_type. Returns 1 if <event_type> is being seem for the last time otherwise returns 0. Returns -1 on error.
Exec a strategy for removing entries. Strategy 1: remove_immediately Strategy 2: remove a bunch_after crossing a threshold Strategy 3: use cached allocator and 1
Definition at line 105 of file Event_Map_T.cpp.
References TAO_Notify_Event_Map_Entry_T< PROXY >::_decr_refcnt(), ACE_READ_GUARD_RETURN, ACE_WRITE_GUARD_RETURN, TAO_Notify_Event_Map_Entry_T< PROXY >::count(), TAO_Notify_Event_Map_Entry_T< PROXY >::disconnected(), TAO_Notify_EventType::is_special(), and TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::map_.
Referenced by TAO_Notify_Event_Manager::un_publish().
00106 { 00107 ENTRY* entry = 0; 00108 00109 if (event_type.is_special () == 1) 00110 { 00111 entry = &this->broadcast_entry_; 00112 00113 entry->disconnected (proxy); 00114 } 00115 else 00116 { 00117 int result = -1; 00118 00119 { 00120 ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); 00121 00122 result = this->map_.find (event_type, entry); 00123 } 00124 00125 if (result == 0) 00126 { 00127 entry->disconnected (proxy); 00128 00129 if (entry->count () == 0) 00130 { 00131 /// Exec a strategy for removing entries. 00132 /// Strategy 1: remove_immediately 00133 /// Strategy 2: remove a bunch_after crossing a threshold 00134 /// Strategy 3: use cached allocator and 1 00135 00136 // Strategy 1: 00137 ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); 00138 00139 this->map_.unbind (event_type); 00140 00141 if (entry->_decr_refcnt () == 0) 00142 delete entry; 00143 00144 if (this->event_types_.remove (event_type) == -1) 00145 return -1; 00146 00147 return 1; 00148 } 00149 } 00150 } 00151 00152 return 0; 00153 }
ACE_INLINE TAO_Notify_Event_Map_Entry_T< PROXY >::COLLECTION * TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::updates_collection | ( | void | ) |
Find the update list. This is all the PROXYS connected to this Map.
Definition at line 60 of file Event_Map_T.inl.
References TAO_Notify_Event_Map_Entry_T< PROXY >::collection(), and TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::updates_entry_.
Referenced by TAO_Notify_Event_Manager::subscription_change().
00061 { 00062 return this->updates_entry_.collection (); 00063 }
ENTRY TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::broadcast_entry_ [protected] |
The default broadcast list for EventType::special.
Definition at line 99 of file Event_Map_T.h.
Referenced by TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::broadcast_collection(), and TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::init().
TAO_Notify_EventTypeSeq TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::event_types_ [protected] |
The event types that are available in this map.
Definition at line 105 of file Event_Map_T.h.
Referenced by TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::event_types().
ACE_LOCK TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::lock_ [protected] |
ACE_Hash_Map_Manager<TAO_Notify_EventType, ENTRY*, ACE_SYNCH_NULL_MUTEX> TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::map_ [protected] |
The Map that stores eventtype to entry mapping.
Definition at line 90 of file Event_Map_T.h.
Referenced by TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::find(), TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::insert(), and TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::remove().
int TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::proxy_count_ [protected] |
Count of proxys connected.
Definition at line 96 of file Event_Map_T.h.
Referenced by TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::connect(), TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::disconnect(), and TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::proxy_count().
ENTRY TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::updates_entry_ [protected] |
Update Entry - Keeps a list of all PROXY's connected to this Map. Updates are send to this list.
Definition at line 102 of file Event_Map_T.h.
Referenced by TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::connect(), TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::disconnect(), TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::init(), and TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::updates_collection().