CORBA::TypeCode_ptr TIDorb::core::typecode::TypeCodeCache::find(CORBA::RepositoryId rep_id) { TIDThr::Synchronized synchro(recursive_mutex); char *pointer = NULL; if (!rep_id) return NULL; int i = 0; for (i = 0; i < m_index; i++) { pointer = m_table[i]->m_repid; if (strcmp(pointer,rep_id) == 0) break; pointer = NULL; } if (pointer) { return CORBA::TypeCode::_duplicate(m_table[i]->m_typecode); } else return NULL; }
bool Thread::doPostWaitCondition() { Synchronized synchro(*m_thread_mutex); m_thread_in_wait = false; return consumeInterruption(); }
Compression::CompressorFactory_ptr TIDorb::core::compression::CompressionManagerImpl::get_factory( Compression::CompressorId compressor_id) throw (Compression::UnknownCompressorId) { TIDThr::Synchronized synchro(m_recursive_mutex); CompressorFactoryMapT::iterator it = m_factories.find(compressor_id); if (it != m_factories.end()) { Compression::CompressorFactory_ptr factory = Compression::CompressorFactory::_duplicate((*it).second); return factory; } else { if ( (compressor_id != Compression::COMPRESSORID_GZIP) && (compressor_id != Compression::COMPRESSORID_PKZIP) && (compressor_id != Compression::COMPRESSORID_BZIP2) && (compressor_id != Compression::COMPRESSORID_ZLIB) && (compressor_id != Compression::COMPRESSORID_LZMA) && (compressor_id != Compression::COMPRESSORID_LZOP) && (compressor_id != Compression::COMPRESSORID_RZIP) && (compressor_id != Compression::COMPRESSORID_7X) && (compressor_id != Compression::COMPRESSORID_XAR) ) throw Compression::UnknownCompressorId(); Compression::CompressorFactory_ptr factory = new TIDorb::core::compression::CompressorFactoryImpl(m_orb, compressor_id); return factory; } }
CORBA::TypeCode_ptr TIDorb::core::typecode::TypeCodeCache::put(CORBA::TypeCode_ptr type) throw (CORBA::INTERNAL) { TIDThr::Synchronized synchro(recursive_mutex); CORBA::RepositoryId rep_id = NULL; try{ rep_id = (char*) type->id(); } catch (const CORBA::TypeCode::BadKind& badKind) { throw CORBA::INTERNAL("Only Complex Typecodes can be put in the cache"); } if (rep_id == NULL) throw CORBA::INTERNAL("Cannot get RepositoryId"); char *pointer = NULL; int i = 0; for (i = 0; i < m_index; i++) { pointer = m_table[i]->m_repid; if (strcmp(pointer,rep_id) == 0) break; pointer = NULL; } if (pointer) { // Anybody use return pointer (duplicate generates mem leak) // return CORBA::TypeCode::_duplicate(m_table[i]->m_typecode); return m_table[i]->m_typecode; } else { if (m_index == m_max) { m_cache** mtable = NULL; m_max *= 2; #if !defined(__linux__) && !defined(__sun) mtable = (m_cache**) new m_cache*[m_max]; #else mtable = new m_cache*[m_max]; #endif memcpy(mtable, m_table, m_max/2*sizeof(m_cache*)); delete[] m_table; m_table = mtable; } m_table[m_index] = new m_cache; m_table[m_index]->m_repid = CORBA::string_dup(rep_id); m_table[m_index++]->m_typecode = type; // Yet duplicate by caller // m_table[m_index++]->m_typecode = CORBA::TypeCode::_duplicate(type); // Anybody use return pointer (duplicate generates mem leak) //return CORBA::TypeCode::_duplicate(type); // is leak if no catch ?? return type; } return NULL; }
void LockPool::put_lock(Lock* lock) { lock->clear(); { TIDThr::Synchronized synchro(*this); locks.push(lock); } }
/** * Increments the counter 1 unity. * @return the new value of the counter. */ CORBA::ULong TIDorb::core::util::Counter::inc() { TIDThr::Synchronized synchro(recursive_mutex); value++; if (value == RESERVED) value++; return value; }
void TIDorb::core::poa::RequestQueue::deactivation() { TIDThr::Synchronized synchro(*this); if(!_deactivation) { _deactivation = true; notifyAll(); } };
/** * Decrements the counter 1 unity. * @return the new value of the counter. */ CORBA::ULong TIDorb::core::util::Counter::dec() { TIDThr::Synchronized synchro(recursive_mutex); if (value > 0) value--; return value; }
// Get epoch data of the network // @gdsMap Object hold epoch observation data of the network // @return Is there more epoch data for the network bool NetworkObsStreams::readEpochData(gnssDataMap& gdsMap) throw(SynchronizeException) { // First, We clear the data map gdsMap.clear(); RinexObsStream* pRefObsStream = mapSourceStream[referenceSource]; gnssRinex gRef; if( (*pRefObsStream) >> gRef ) { gdsMap.addGnssRinex(gRef); std::map<SourceID, RinexObsStream*>::iterator it; for( it = mapSourceStream.begin(); it != mapSourceStream.end(); ++it) { if( it->first == referenceSource) continue; Synchronize synchro( (*(*it).second), gRef); gnssRinex gRin; try { gRin >> synchro; gdsMap.addGnssRinex(gRin); } catch(...) { if(synchronizeException) { std::stringstream ss; ss << "Exception when try to synchronize at epoch: " << gRef.header.epoch << std::endl; SynchronizeException e(ss.str()); GPSTK_THROW(e); } } } // End of 'for(std::map<SourceID, RinexObsStream*>::iterator it; return true; } // End of 'if( (*pRefObsStream) >> gRef )' return false; } // End of method 'NetworkObsStreams::readEpochData()'
void TIDorb::core::comm::UDPConnection::write_Version_1_1( const TIDorb::core::comm::iiop::GIOPMessage& message, const TIDorb::core::comm::iiop::RequestId request_id) { TIDorb::core::cdr::BufferCDR* buffer = message.get_message_buffer(); size_t num_chunks = buffer->get_num_available_chunks(); TIDorb::core::cdr::ChunkCDR* chunk = NULL; { TIDThr::Synchronized synchro(write_mutex); // Start a new MIOP Packet Collection TIDorb::core::comm::miop::MIOPPacket packet( TIDorb::core::comm::miop::Version::VERSION_1_0, // TODO: add timestamp or MAC address // (~((TIDorb::core::comm::miop::UniqueId) request_id) + // _orb->getTimeStamp()), (TIDorb::core::comm::miop::UniqueId) request_id, miop_packet_buffer, num_chunks); if (_orb->trace != NULL) { TIDorb::util::StringBuffer msg; msg << "Sending MIOP packet collection id="; msg << request_id <<" chunks="<< num_chunks; _orb->print_trace(TIDorb::util::TR_DEEP_DEBUG, msg.str().data()); } for (size_t i = 0; i < num_chunks; i++) { chunk = buffer->get_chunk(i); size_t packet_size = packet.preparePacket( (unsigned char*) chunk->get_buffer(), chunk->get_length(), i, chunk->get_available_bytes()); write(packet.getPacketBuffer(), packet_size, 0, packet_size); if (_orb->trace != NULL) { TIDorb::util::StringBuffer msg; msg << "GIOP message chunk sent - HEXDUMP " << packet_size << " bytes"; _orb->print_trace(TIDorb::util::TR_DUMP, msg.str().data()); _orb->print_dump(TIDorb::util::TR_DUMP, (const unsigned char*)packet.getPacketBuffer(), packet_size); } // Delay if (delay.tv_nsec) nanosleep(&delay, NULL); } } }
/*synchronized*/ void Thread::start() throw (IllegalThreadStateException) { // prevent this method from ending before the thread has dead ThreadHandle my_handle = this; { Synchronized synchro(*m_thread_mutex); if(m_thread_state == TIDTHR_ERROR) { throw IllegalThreadStateException ("Thread::start() Invalid Object"); } else if(m_thread_state == TIDTHR_RUNNING) { throw IllegalThreadStateException ("Thread::start() Thread already Running"); } else if(m_thread_state == TIDTHR_DEAD) { throw IllegalThreadStateException ("Thread::start() Thread is dead"); } const pthread_attr_t* attr = (m_thread_attributes == NULL)? m_thread_group->getAttributes() : m_thread_attributes; int ret; ThreadHandle* handle = new ThreadHandle(this); if(m_thread_daemon) { st_thread_counter->inc(); } pthread_t thread_desc; //PRA ret = pthread_create(&thread_desc, attr, (pthread_function_t) st_perform_run, handle); if(ret) { delete handle; m_thread_state = TIDTHR_ERROR; if(m_thread_daemon) { st_thread_counter->dec(); } throw IllegalThreadStateException("Thread::start()", ret); } //EPRA } }
void TIDorb::core::compression::CompressionManagerImpl::unregister_factory( Compression::CompressorId compressor_id) throw (Compression::UnknownCompressorId) { TIDThr::Synchronized synchro(m_recursive_mutex); CompressorFactoryMapT::iterator it = m_factories.find(compressor_id); if (it != m_factories.end()) { m_factories.erase(it); } else throw Compression::UnknownCompressorId(); }
void TIDorb::core::poa::RequestQueue::setComparator( TIDorb::core::poa::RequestComparatorType type) { if ( _comparator_type != type){ TIDThr::Synchronized synchro(*this); this->discardAll(); switch (_comparator_type){ case PRIORITY_REQUEST_COMPARATOR: delete _priority_value; break; case DEADLINE_REQUEST_COMPARATOR: delete _deadline_value; break; case TEMPORAL_REQUEST_COMPARATOR: delete _temporal_value; break; default: delete _value; break; } switch (type){ case PRIORITY_REQUEST_COMPARATOR: _priority_value = new priority_queue<TIDorb::core::poa::QueuedRequest*, deque<TIDorb::core::poa::QueuedRequest*>, PriorityRequestComparator<QueuedRequest*> >; break; case DEADLINE_REQUEST_COMPARATOR: _deadline_value = new priority_queue<TIDorb::core::poa::QueuedRequest*, deque<TIDorb::core::poa::QueuedRequest*>, DeadlineRequestComparator<QueuedRequest*> >; break; case TEMPORAL_REQUEST_COMPARATOR: _temporal_value = new priority_queue<TIDorb::core::poa::QueuedRequest*, deque<TIDorb::core::poa::QueuedRequest*>, TemporalRequestComparator<QueuedRequest*> >; break; default: _value = new simple_queueT; type = TIDorb::core::poa::NULL_REQUEST_COMPARATOR; break; } _comparator_type = type; } };
Lock* LockPool::get_lock() { TIDThr::Synchronized synchro(*this); Lock* lock = NULL; if(locks.size() > 0) { lock = locks.top(); lock->recycle(); locks.pop(); } else { lock = new Lock(); } return lock; }
void TIDorb::core::compression::CompressionManagerImpl::register_factory( Compression::CompressorFactory_ptr compressor_factory) throw (Compression::FactoryAlreadyRegistered) { TIDThr::Synchronized synchro(m_recursive_mutex); Compression::CompressorId comp_id = compressor_factory->compressor_id(); CompressorFactoryMapT::iterator it = m_factories.find(comp_id); if (it == m_factories.end()) { m_factories[comp_id] = compressor_factory; } else throw Compression::FactoryAlreadyRegistered(); }
Compression::Compressor_ptr TIDorb::core::compression::CompressionManagerImpl::get_compressor( Compression::CompressorId compressor_id, Compression::CompressionLevel compression_level) throw (Compression::UnknownCompressorId) { TIDThr::Synchronized synchro(m_recursive_mutex); CompressorFactoryMapT::iterator it = m_factories.find(compressor_id); if (it != m_factories.end()) { Compression::CompressorFactory_var factory = Compression::CompressorFactory::_duplicate((*it).second); return factory->get_compressor(compression_level); } else throw Compression::UnknownCompressorId(); }
void TIDorb::core::iop::ORBComponent::write(TIDorb::core::cdr::CDROutputStream& out) const { TIDThr::Synchronized synchro(*((ORBComponent*)this)); if(!_component_data) { TIDorb::core::cdr::CDROutputStream encapsulation ((TIDorb::core::TIDORB*)(out.orb()), new TIDorb::core::cdr::BufferCDR( 2 * TIDorb::core::cdr::CDR::ULONG_SIZE)); encapsulation.write_boolean(encapsulation.get_byte_order()); encapsulation.write_ulong(orb_type); ((ORBComponent*) this)->_component_data = (TIDorb::core::cdr::CDRInputStream* ) (encapsulation.create_input_stream()); } TaggedComponent::write(out); }
TIDorb::core::poa::QueuedRequest* TIDorb::core::poa::RequestQueue::get() { TIDThr::Synchronized synchro(*this); if (this->size() == 0) { if(_deactivation) { return NULL; } try { wait(_starving_time); } catch(TIDThr::InterruptedException &ie) {} if (this->size() == 0) { return NULL; } } QueuedRequest* req; switch (_comparator_type){ case PRIORITY_REQUEST_COMPARATOR: req = _priority_value->top(); _priority_value->pop(); break; case DEADLINE_REQUEST_COMPARATOR: req = _deadline_value->top(); _deadline_value->pop(); break; case TEMPORAL_REQUEST_COMPARATOR: req = _temporal_value->top(); _temporal_value->pop(); break; default: req = _value->front(); _value->pop_front(); break; } return req; };
void Thread::setDaemon(bool value) { Synchronized synchro(*m_thread_mutex); if(!value) { if(m_thread_daemon) { m_thread_daemon = false; if(m_thread_state == TIDTHR_RUNNING) { st_thread_counter->dec(); } } } else { if(!m_thread_daemon) { m_thread_daemon = true; if(m_thread_state == TIDTHR_RUNNING) { st_thread_counter->inc(); } } } }
Compression::CompressorFactorySeq* TIDorb::core::compression::CompressionManagerImpl::get_factories() { TIDThr::Synchronized synchro(m_recursive_mutex); Compression::CompressorFactorySeq* factories = new Compression::CompressorFactorySeq(); factories->length(m_factories.size()); CompressorFactoryMapT::iterator it; CompressorFactoryMapT::iterator end = m_factories.end(); CORBA::ULong i = 0; for (it = m_factories.begin(); it != end; it++) { (*factories)[i] = Compression::CompressorFactory::_duplicate((*it).second); i++; } return factories; }
void Thread::interrupt() throw (IllegalThreadStateException) { Synchronized synchro(*m_thread_mutex); int ret = 0; if(m_thread_state == TIDTHR_ERROR) { throw IllegalThreadStateException ("Thread::interrupt() Invalid Object",ret); } if(m_thread_in_wait == true) { m_thread_wait_interrupted = true; } ret = pthread_kill(m_thread_id.value(),SIGINT); if(ret) { throw IllegalThreadStateException ("Thread::interrupt() Invalid Object",ret); } };
void TIDorb::core::poa::RequestQueue::add(TIDorb::core::poa::QueuedRequest* request) { TIDThr::Synchronized synchro(*this); if ( (_deactivation) || // (this->size() >= (_poaManager->conf->getMaxQueuedRequests() (this->size() >= (_maxAvailableRequests //+ _poaManager->conf->getMaxThreads() - _thread_pool->getActives())) ) { request->returnError(CORBA::TRANSIENT(NULL, 1, CORBA::COMPLETED_NO), _poaManager->orb->trace); // Destroy actual request because cannot be inserted in queue request request->destroy(); return; } switch (_comparator_type){ case PRIORITY_REQUEST_COMPARATOR: _priority_value->push(request); break; case DEADLINE_REQUEST_COMPARATOR: _deadline_value->push(request); break; case TEMPORAL_REQUEST_COMPARATOR: _temporal_value->push(request); break; default: _value->push_back(request); break; } if (!_reader->createNewReader()) { notify(); } };
bool TIDorb::core::util::Counter::non_zero() { TIDThr::Synchronized synchro(recursive_mutex); return (value != 0); }
CORBA::ULong TIDorb::core::util::Counter::get_value() { TIDThr::Synchronized synchro(recursive_mutex); return value; }
bool Thread::consumeInterruptionSync() { Synchronized synchro(*m_thread_mutex); return consumeInterruption(); };
void TIDorb::core::comm::iiop::ProfileIIOP::extract_members() { if(!_components_extracted) { TIDThr::Synchronized synchro(*this); if(_components_extracted) // May be changed after return of synchro return; if(_profile_data == NULL) throw CORBA::INTERNAL("Empty Profile"); _version.read(*_profile_data); //_listen_point.read(*_profile_data); TIDorb::core::comm::iiop::ListenPoint point; point.read(*_profile_data); // _listen_points.clear(); // _listen_points.push_back(point); _object_key = new ObjectKey(); _object_key->read(*_profile_data); if(_version > Version::VERSION_1_0) { CORBA::ULong size; _profile_data->read_ulong(size); if (size < 0) { throw CORBA::MARSHAL("Invalid component size"); } else { _components.resize(size); for(size_t i = 0; i < size; i++) { //_components[i] = TIDorb::core::iop::TaggedComponentReader::read(*_profile_data); TIDorb::core::iop::TaggedComponent* comp; comp = TIDorb::core::iop::TaggedComponentReader::read(*_profile_data); _components[i] = comp; if (comp->_tag == TIDorb::core::iop::TAG_POLICIES) { TIDorb::core::messaging::PoliciesComponent* policies_component = dynamic_cast<TIDorb::core::messaging::PoliciesComponent*>(comp); _policies = policies_component->getPolicies(); } if (comp->_tag == TIDorb::core::iop::TAG_SSL_SEC_TRANS) { TIDorb::core::comm::ssliop::SSLComponent* ssl_component = dynamic_cast<TIDorb::core::comm::ssliop::SSLComponent*>(comp); point._ssl_port = ssl_component->getSSLPort(); _ssl = new SSLIOP::SSL((const SSLIOP::SSL&)*(ssl_component->getSSL())); } if (comp->_tag == TIDorb::core::iop::TAG_CSI_SEC_MECH_LIST) { TIDorb::core::security::CSIComponent* csi_component = dynamic_cast<TIDorb::core::security::CSIComponent*>(comp); _compound_sec_mechs = new CSIIOP::CompoundSecMechList((const CSIIOP::CompoundSecMechList&) *(csi_component->getCompoundSecMechList())); } TIDorb::core::comm::FT::AlternateIIOPAddress* addr; addr = dynamic_cast<TIDorb::core::comm::FT::AlternateIIOPAddress*>(comp); if (addr) _listen_points.push_back(addr->_listen_point); } } } _listen_points.clear(); _listen_points.push_back(point); _components_extracted = true; } }
int initframe_alignment(int numsamples, int FFTsize, _Complex float *in, _Complex float *correl,\ _Complex float *coeff0, _Complex float *coeff1, _Complex float *coeff2, synchctrl_t *subframCtrl){ int i,j,k; int corrdtect=0, pointer; /** Point to the max value in correlation sequence*/ p2MAX_t corrINFO; //Detect the first PSS memset(&corrINFO, 0, sizeof(p2MAX_t)); if(subframCtrl->synchstate==SYNCH_INIT){ modinfo("////////////////////////////////////SYNCH_INIT\n"); corrdtect=synchro(numsamples, FFTsize, in, correl, coeff0, coeff1, coeff2, &corrINFO); modinfo_msg("SYNCHRO OUTPUT: corrdtect = %d\n",corrdtect); if(corrdtect == 0) { //NO Correl Max found subframCtrl->synchstate=SYNCH_INIT; return 0; } if(corrdtect == -1){ subframCtrl->synchstate=SYNCH_ERROR; moderror_msg("Synchronization error synchState=%d\n", subframCtrl->synchstate); return -1; } if(corrdtect == 1){ subframCtrl->synchstate=SYNCH_TRACK; subframCtrl->p2_OFDMPSS = corrINFO.pMAX-FFTsize; //Pointer to the FFT symbol, after CP subframCtrl->PSSseq = corrINFO.seqNumber; subframCtrl->nofsubframe = 0; subframCtrl->nofslot = 0; //modinfo_msg("p2_OFDMPSS=%d\n", subframCtrl->p2_OFDMPSS); return 1; } moderror_msg("Invalid value for corrdtect=%d \n", corrdtect); return 0; } if(subframCtrl->synchstate==SYNCH_TRACK && (subframCtrl->nofsubframe == 0 || subframCtrl->nofsubframe == 5)){ modinfo("////////////////////////////////////SYNCH_TRACK\n"); corrdtect=synchro(numsamples, FFTsize, in/*+pointer*/, correl, coeff0, coeff1, coeff2, &corrINFO); modinfo_msg("SYNCHRO OUTPUT: corrdtect = %d\n",corrdtect); if(corrdtect == 0) { //NO Correl Max found subframCtrl->synchstate=SYNCH_INIT; return 0; } if(corrdtect == -1){ subframCtrl->synchstate=SYNCH_ERROR; moderror_msg("Synchronization error synchState=%d\n", subframCtrl->synchstate); return -1; } if(corrdtect == 1){ subframCtrl->synchstate=SYNCH_TRACK; subframCtrl->p2_OFDMPSS = /*pointer+*/corrINFO.pMAX-FFTsize; subframCtrl->nofsubframe = 0; subframCtrl->nofslot = 0; modinfo_msg("p2_OFDMPSS=%d\n", subframCtrl->p2_OFDMPSS); return 1; } moderror_msg("Invalid value for corrdtect=%d \n", corrdtect); return 0; } return 0; }
void Thread::setPriority(int value) throw (IllegalThreadStateException, IllegalArgumentException) { if(m_thread_state == TIDTHR_ERROR) { throw IllegalThreadStateException ("Thread::setPriority() Invalid Object"); } sched_param param; int policy; int ret; /*synchronized(thread_mutex) */ { Synchronized synchro(*m_thread_mutex); if(m_thread_state == TIDTHR_CREATED) { if(m_thread_attributes == NULL) { m_thread_attributes = (pthread_attr_t *) malloc(sizeof(pthread_attr_t)); pthread_attr_init(m_thread_attributes); ThreadGroup::attrCopy(m_thread_group->getAttributes(), m_thread_attributes); } pthread_attr_getschedparam(m_thread_attributes, ¶m); param.sched_priority = value; ret = pthread_attr_setschedparam(m_thread_attributes, ¶m); if(ret) { throw IllegalArgumentException ("Thread::setPriority(int value)",ret); } return; } } // end sinchronized(thread_mutex) //THREAD RUNNING OR DEATH ret = pthread_getschedparam(m_thread_id.value(), &policy, ¶m); if(ret) { throw IllegalThreadStateException ("Thread::setPriority(int value) pthread_getschedparam(): " "thread is dead",ret); } param.sched_priority = value; ret = pthread_setschedparam(m_thread_id.value(),policy, ¶m); if(!ret) { return; } else if(ret == ESRCH) { throw IllegalThreadStateException ("Thread::setPriority(int value) pthread_setchdparam(): " "thread is dead",ret); } else { throw IllegalArgumentException("Thread::setPriority(int value)",ret); } } // ThreadGroup &getThreadGroup();
void Thread::doPreWaitCondition() { Synchronized synchro(*m_thread_mutex); m_thread_in_wait = true; };