38 throw CORBA::OBJECT_NOT_EXIST();
46 throw CORBA::OBJECT_NOT_EXIST();
54 throw CORBA::OBJECT_NOT_EXIST();
59 DB(5,
"EventChannel_i::destroy()")
70 :
Servant(PortableServer::POA::_nil()),
84 const char* channelName,
129 DB(20,
"~EventChannel_i()")
156 assert(!CORBA::is_nil(
_poa));
158 const char* action=
"";
163 action=
"add this object to the store";
169 action=
"create this object in the persistency database";
175 action=
"run main loop";
180 action=
"remove this object from the store";
188 action=
"remove record from persistency database";
189 CORBA::String_var poaName =
_poa->the_name();
191 log.
os<<
"-ecf/"<<poaName.in()<<
'\n';
193 action=
"destroy POA";
198 _poa=PortableServer::POA::_nil();
203 catch(PortableServer::POAManager::AdapterInactive& ex) {
204 DB(0,
"EventChannel_i::run_undetached() - failed to "<<action<<
205 ", POA deactivated from the outside.")
207 catch (CORBA::SystemException& ex) {
208 DB(0,
"EventChannel_i::run_undetached() - failed to "<<action<<
209 ", System exception: "<<ex._name()<<
" ("<<
NP_MINORSTRING(ex)<<
")")
211 catch (CORBA::Exception& ex) {
212 DB(0,
"EventChannel_i::run_undetached() - failed to "<<action<<
213 ", CORBA exception: "<<ex._name())
233 list<CORBA::Any*> events;
236 assert(events.empty());
243 omni_thread::sleep(0,localCyclePeriod_ns);
250 #if OMNIEVENTS__DEBUG_REF_COUNTS 251 DB(20,
"EventChannel_i::_add_ref()")
253 omni_mutex_lock pause(
_lock);
260 #if OMNIEVENTS__DEBUG_REF_COUNTS 261 DB(20,
"EventChannel_i::_remove_ref()")
265 omni_mutex_lock pause(
_lock);
271 DB(2,
"EventChannel has negative ref count! "<<myref)
275 DB(15,
"EventChannel has zero ref count -- shutdown.")
283 CORBA::String_var poaName =
_poa->the_name();
284 string name =string(
"ecf/")+poaName.in();
304 CORBA::Object_var obj( _this() );
305 newMapper=
new Mapper(v.c_str(),obj.in());
324 using namespace PortableServer;
336 CORBA::PolicyList policies;
338 policies[0]=p->create_lifespan_policy(PERSISTENT);
339 policies[1]=p->create_id_assignment_policy(USER_ID);
340 policies[2]=p->create_thread_policy(SINGLE_THREAD_MODEL);
348 _poa=p->create_POA(channelName,POAManager::_nil(),policies);
351 catch(POA::AdapterAlreadyExists& ex)
353 DB(0,
"EventChannel_i::createPoa() - POA::AdapterAlreadyExists")
356 catch(POA::InvalidPolicy& ex)
358 DB(0,
"EventChannel_i::createPoa() - POA::InvalidPolicy: "<<ex.index)
365 for(CORBA::ULong i=0; i<policies.length(); ++i)
371 for(CORBA::ULong i=0; i<policies.length(); ++i)
392 omni_mutex_lock l(
_lock);
393 bool insertOK =
_channels.insert(channel).second;
395 DB(2,
"Attempted to store an EventChannel, when it is already stored.");
400 omni_mutex_lock l(
_lock);
401 set<EventChannel_i*>::iterator pos =
_channels.find(channel);
403 DB(2,
"Failed to erase unknown EventChannel.")
410 omni_mutex_lock l(
_lock);
411 for(set<EventChannel_i*>::iterator i=
_channels.begin();
PersistNode * child(const string &key) const
void _remove_ref()
Shutdown the thread when refCount reaches zero.
#define NP_MINORSTRING(systemException)
OMNIEVENTS__DEBUG_REF_COUNTS__DECL void send(CORBA::Any *event)
Queues a single event for sending to consumers.
set< EventChannel_i * > _channels
A dummy servant that installs itself into the INSPOA and redirects all calls to the real destination...
void mainLoop()
The main loop for a channel.
void erase(EventChannel_i *channel)
void disconnect()
Send disconnect_XXX_supplier() to all connected consumers.
void createPoa(const char *channelName)
Constructs the main POA for this channel.
EventChannel_i(EventChannelStore *store=NULL)
void activate(const char *channelName, const PersistNode *node=NULL)
Creates the channel's POA, and any child objects.
void output(ostream &os)
Save this object's state to a stream.
string attrString(const string &key, const string &fallback="") const
void reincarnate(const PersistNode &node)
Populate this servant from log information.
map< string, string > _attr
PortableServer::POA_var _RootPOA
static bool exists()
Library code may create Event Service objects without the need for persistency.
Container for Event Channels.
ConsumerAdmin_i * _consumerAdmin
PortableServer::POAManager_var _poaManager
void output(ostream &os, string name) const
SupplierAdmin_i * _supplierAdmin
EventChannelStore * _eventChannelStore
unsigned long cyclePeriod_ns() const
PortableServer::POA_var _poa
~EventChannel_i()
Cleans up the _poa, if this object is deleted before its thread starts.
void activateObjectWithId(const char *oidStr)
Calls activate_object_with_id() to activate this servant in its POA.
CosEventChannelAdmin::ConsumerAdmin_ptr for_consumers()
void disconnect()
Send disconnect_XXX_consumer() to all connected consumers.
Obtains an output stream to the active persistancy logfile, and locks it for exclusive access...
void insert(EventChannel_i *channel)
void * run_undetached(void *)
Entry point for the channel's thread.
CosEventChannelAdmin::SupplierAdmin_ptr for_suppliers()
void setInsName(const string v)
Construct a new Mapper object, and registers it in the INSPOA.
void output(ostream &os)
Save this object's state to a stream.
OMNIEVENTS__DEBUG_REF_COUNTS__DECL void collect(list< CORBA::Any * > &events)
Collects all events that have arrived since the last call.
Servant for CosEventChannelAdmin::EventChannel objects, also inherits from omni_thread.
void reincarnate(const PersistNode &node)
Populate this servant from log information.