OmniEvents
OmniEvents::EventChannel_i Class Reference

Servant for CosEventChannelAdmin::EventChannel objects, also inherits from omni_thread. More...

#include <EventChannel.h>

Inheritance diagram for OmniEvents::EventChannel_i:
Collaboration diagram for OmniEvents::EventChannel_i:

Public Member Functions

CosEventChannelAdmin::ConsumerAdmin_ptr for_consumers ()
 
CosEventChannelAdmin::SupplierAdmin_ptr for_suppliers ()
 
void destroy ()
 
CORBA::Boolean is_alive ()
 'ping' method inherited from FT::PullMonitorable. More...
 
 EventChannel_i (EventChannelStore *store=NULL)
 
 ~EventChannel_i ()
 Cleans up the _poa, if this object is deleted before its thread starts. More...
 
void activate (const char *channelName, const PersistNode *node=NULL)
 Creates the channel's POA, and any child objects. More...
 
void start ()
 Warn about interface change. More...
 
void * run_undetached (void *)
 Entry point for the channel's thread. More...
 
void mainLoop ()
 The main loop for a channel. More...
 
void _add_ref ()
 
void _remove_ref ()
 Shutdown the thread when refCount reaches zero. More...
 
void output (ostream &os)
 
ConsumerAdmin_iconsumerAdmin () const
 
const PersistNodeproperties () const
 
CORBA::ULong pullRetryPeriod_ms () const
 
CORBA::ULong maxQueueLength () const
 
CORBA::ULong maxNumProxies () const
 
unsigned long cyclePeriod_ns () const
 
- Public Member Functions inherited from OmniEvents::Servant
virtual PortableServer::POA_ptr _default_POA ()
 
virtual ~Servant ()
 

Private Member Functions

void setInsName (const string v)
 Construct a new Mapper object, and registers it in the INSPOA. More...
 
void createPoa (const char *channelName)
 Constructs the main POA for this channel. More...
 

Private Attributes

EventChannelStore_eventChannelStore
 
SupplierAdmin_i_supplierAdmin
 
ConsumerAdmin_i_consumerAdmin
 
PortableServer::POAManager_var _poaManager
 
bool _shutdownRequested
 
PersistNode _properties
 
Mapper_mapper
 
omni_mutex _lock
 
int _refCount
 

Additional Inherited Members

- Protected Member Functions inherited from OmniEvents::Servant
 Servant (PortableServer::POA_ptr poa)
 
void activateObjectWithId (const char *oidStr)
 Calls activate_object_with_id() to activate this servant in its POA. More...
 
void deactivateObject ()
 Calls deactivate_object() to deactivate this servant in its POA. More...
 
- Protected Attributes inherited from OmniEvents::Servant
PortableServer::POA_var _poa
 

Detailed Description

Servant for CosEventChannelAdmin::EventChannel objects, also inherits from omni_thread.

Each EventChannel contains five POAs, one for each of the proxy types, and one for the XXXAdmins and EventChannel itself. This POA also contains the ProxyManager objects that are used to manage three of the four proxy object types.

Here's a summary of the POAs, and their contents:

    +-POA: EventChannel-----------------------------------------------+
    |                                                                 |
    |                      Obj: EventChannel_i                        |
    |                                                                 |
    |       Obj: SupplierAdmin_i           Obj: ConsumerAdmin_i       |
    |                                                                 |
    |                                 Obj: ProxyPushSupplierManager   |
    |                                                                 |
    |   +-POA: ProxyPushConsumer---+   +-POA: ProxyPushSupplier---+   |
    |   |                          |   |                          |   |
    |   | Obj: ProxyPushConsumer_i |   | Obj: ProxyPushSupplier_i |   |
    |   | (DEFAULT SERVANT)        |   | Obj: ProxyPushSupplier_i |   |
    |   |                          |   | Obj: ProxyPushSupplier_i |   |
    |   |                          |   | .                        |   |
    |   |                          |   | .                        |   |
    |   |                          |   | .                        |   |
    |   |                          |   |                          |   |
    |   +--------------------------+   +--------------------------+   |
    |                                                                 |
    |  Obj: ProxyPullConsumerManager  Obj: ProxyPullSupplierManager   |
    |                                                                 |
    |   +-POA: ProxyPullConsumer---+   +-POA: ProxyPullSupplier---+   |
    |   |                          |   |                          |   |
    |   | Obj: ProxyPullConsumer_i |   | Obj: ProxyPullSupplier_i |   |
    |   | Obj: ProxyPullConsumer_i |   | Obj: ProxyPullSupplier_i |   |
    |   | Obj: ProxyPullConsumer_i |   | Obj: ProxyPullSupplier_i |   |
    |   | .                        |   | .                        |   |
    |   | .                        |   | .                        |   |
    |   | .                        |   | .                        |   |
    |   |                          |   |                          |   |
    |   +--------------------------+   +--------------------------+   |
    |                                                                 |
    +-----------------------------------------------------------------+

All five POAs are single threaded, and managed by the same POAmanager. This enables the top level event loop (EventChannel::run()) to hold all incoming calls while it passes events from the ProxyConsumers over to the ProxySuppliers. This single threaded model simplifies[*] the implementation and avoids all of the locking overheads of a multi-threaded solution.

[*] That's the theory anyway... Actually the single threaded model complicates the underlying implementation, because omniORB treats single threaded POAs as a special case on top of multi-threaded ones, rather than the other way round! Ironic!

Definition at line 111 of file EventChannel.h.

Constructor & Destructor Documentation

◆ EventChannel_i()

OmniEvents::EventChannel_i::EventChannel_i ( EventChannelStore store = NULL)

Definition at line 69 of file EventChannel.cc.

◆ ~EventChannel_i()

OmniEvents::EventChannel_i::~EventChannel_i ( )

Cleans up the _poa, if this object is deleted before its thread starts.

Definition at line 127 of file EventChannel.cc.

References _consumerAdmin, _mapper, _supplierAdmin, DB, and OmniEvents::Mapper::destroy().

Member Function Documentation

◆ _add_ref()

void OmniEvents::EventChannel_i::_add_ref ( )

Definition at line 248 of file EventChannel.cc.

References _lock, _refCount, and DB.

◆ _remove_ref()

void OmniEvents::EventChannel_i::_remove_ref ( )

Shutdown the thread when refCount reaches zero.

Definition at line 258 of file EventChannel.cc.

References _lock, _refCount, and DB.

Referenced by activate().

◆ activate()

void OmniEvents::EventChannel_i::activate ( const char *  channelName,
const PersistNode node = NULL 
)

◆ consumerAdmin()

ConsumerAdmin_i& OmniEvents::EventChannel_i::consumerAdmin ( ) const
inline

Definition at line 168 of file EventChannel.h.

Referenced by OmniEvents::SupplierAdmin_i::SupplierAdmin_i().

◆ createPoa()

void OmniEvents::EventChannel_i::createPoa ( const char *  channelName)
private

Constructs the main POA for this channel.

Policies are: PERSISTENT, USER_ID, SINGLE_THREAD_MODEL. POA name is set to channelName.

Definition at line 322 of file EventChannel.cc.

References OmniEvents::Servant::_poa, _poaManager, OmniEvents::Orb::_RootPOA, DB, destroy(), and OmniEvents::Orb::inst().

Referenced by activate().

◆ cyclePeriod_ns()

unsigned long OmniEvents::EventChannel_i::cyclePeriod_ns ( ) const
inline

Definition at line 181 of file EventChannel.h.

References CYCLE_PERIOD_NS.

Referenced by mainLoop(), and OmniEvents::SupplierAdmin_i::SupplierAdmin_i().

◆ destroy()

void OmniEvents::EventChannel_i::destroy ( )

◆ for_consumers()

CosEventChannelAdmin::ConsumerAdmin_ptr OmniEvents::EventChannel_i::for_consumers ( )

Definition at line 35 of file EventChannel.cc.

References _consumerAdmin, and _shutdownRequested.

◆ for_suppliers()

CosEventChannelAdmin::SupplierAdmin_ptr OmniEvents::EventChannel_i::for_suppliers ( )

Definition at line 43 of file EventChannel.cc.

References _shutdownRequested, and _supplierAdmin.

◆ is_alive()

CORBA::Boolean OmniEvents::EventChannel_i::is_alive ( )
inline

'ping' method inherited from FT::PullMonitorable.

Definition at line 121 of file EventChannel.h.

◆ mainLoop()

void OmniEvents::EventChannel_i::mainLoop ( )

The main loop for a channel.

Work is strictly separated into two phases. Most of the time, all of the POAs are active, and receiving incoming calls. Periodically, incoming calls are held and the channel collects new events from the consumers and sends them to the suppliers.

Incoming call handlers are all designed to complete in the absolute minimum time. This enables the POAs to be single threaded, and to hold incoming calls without having to wait a long time for ongoing invokations to complete. Sadly, it's not possible to implement ProxyPullSupplier::pull() 'properly' without blocking, so our version just raises TRANSIENT if there is no event immediately available.

Outgoing calls are always sent as deferred requests, to avoid blocking while we wait for them to return.

Definition at line 221 of file EventChannel.cc.

References _consumerAdmin, _poaManager, _refCount, _shutdownRequested, _supplierAdmin, OmniEvents::SupplierAdmin_i::collect(), cyclePeriod_ns(), and OmniEvents::ConsumerAdmin_i::send().

Referenced by run_undetached().

◆ maxNumProxies()

CORBA::ULong OmniEvents::EventChannel_i::maxNumProxies ( ) const
inline

Definition at line 179 of file EventChannel.h.

References MAX_NUM_PROXIES.

Referenced by OmniEvents::ProxyPullSupplierManager::incarnate().

◆ maxQueueLength()

CORBA::ULong OmniEvents::EventChannel_i::maxQueueLength ( ) const
inline

Definition at line 177 of file EventChannel.h.

References MAX_QUEUE_LENGTH.

◆ output()

◆ properties()

const PersistNode& OmniEvents::EventChannel_i::properties ( ) const
inline

Definition at line 170 of file EventChannel.h.

Referenced by OmniEvents::ConsumerAdmin_i::ConsumerAdmin_i().

◆ pullRetryPeriod_ms()

CORBA::ULong OmniEvents::EventChannel_i::pullRetryPeriod_ms ( ) const
inline

Definition at line 175 of file EventChannel.h.

References PULL_RETRY_PERIOD_MS.

Referenced by OmniEvents::SupplierAdmin_i::SupplierAdmin_i().

◆ run_undetached()

void * OmniEvents::EventChannel_i::run_undetached ( void *  )

Entry point for the channel's thread.

Calls mainLoop() and waits for it to exit. Handles any exceptions, and shuts down the channel once the main loop has finished.

Definition at line 153 of file EventChannel.cc.

References _eventChannelStore, OmniEvents::Servant::_poa, _shutdownRequested, DB, OmniEvents::EventChannelStore::erase(), OmniEvents::omniEventsLog::exists(), OmniEvents::EventChannelStore::insert(), mainLoop(), NP_MINORSTRING, OmniEvents::WriteLock::os, and output().

◆ setInsName()

void OmniEvents::EventChannel_i::setInsName ( const string  v)
private

Construct a new Mapper object, and registers it in the INSPOA.

Definition at line 293 of file EventChannel.cc.

References _mapper, and OmniEvents::Mapper::destroy().

Referenced by activate().

◆ start()

void OmniEvents::EventChannel_i::start ( )
inline

Warn about interface change.

Definition at line 135 of file EventChannel.h.

References DB.

Member Data Documentation

◆ _consumerAdmin

ConsumerAdmin_i* OmniEvents::EventChannel_i::_consumerAdmin
private

Definition at line 198 of file EventChannel.h.

Referenced by activate(), destroy(), for_consumers(), mainLoop(), output(), and ~EventChannel_i().

◆ _eventChannelStore

EventChannelStore* OmniEvents::EventChannel_i::_eventChannelStore
private

Definition at line 196 of file EventChannel.h.

Referenced by run_undetached().

◆ _lock

omni_mutex OmniEvents::EventChannel_i::_lock
private

Definition at line 203 of file EventChannel.h.

Referenced by _add_ref(), and _remove_ref().

◆ _mapper

Mapper* OmniEvents::EventChannel_i::_mapper
private

Definition at line 202 of file EventChannel.h.

Referenced by setInsName(), and ~EventChannel_i().

◆ _poaManager

PortableServer::POAManager_var OmniEvents::EventChannel_i::_poaManager
private

Definition at line 199 of file EventChannel.h.

Referenced by createPoa(), and mainLoop().

◆ _properties

PersistNode OmniEvents::EventChannel_i::_properties
private

Definition at line 201 of file EventChannel.h.

Referenced by activate(), and output().

◆ _refCount

int OmniEvents::EventChannel_i::_refCount
private

Definition at line 204 of file EventChannel.h.

Referenced by _add_ref(), _remove_ref(), and mainLoop().

◆ _shutdownRequested

bool OmniEvents::EventChannel_i::_shutdownRequested
private

Definition at line 200 of file EventChannel.h.

Referenced by destroy(), for_consumers(), for_suppliers(), mainLoop(), and run_undetached().

◆ _supplierAdmin

SupplierAdmin_i* OmniEvents::EventChannel_i::_supplierAdmin
private

Definition at line 197 of file EventChannel.h.

Referenced by activate(), destroy(), for_suppliers(), mainLoop(), output(), and ~EventChannel_i().


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