CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/DQMServices/XdaqCollector/src/ToDqm.cc

Go to the documentation of this file.
00001 #include "DQMServices/XdaqCollector/interface/ToDqm.h"
00002 //#include "FWCore/ServiceRegistry/interface/Service.h"
00003 
00004 
00005 xmas2dqm::wse::ToDqm * xmas2dqm::wse::ToDqm::instance_ = 0;
00006 xmas2dqm::wse::ToDqm * xmas2dqm::wse::ToDqm::instance()
00007 {
00008         if(instance_ == 0) instance_ = new xmas2dqm::wse::ToDqm(); return instance_;
00009 }
00010 
00011 xmas2dqm::wse::ToDqm::ToDqm() : BSem_(toolbox::BSem::FULL),messageCount_(0)
00012 {
00013         //std::cout << "ToDqm constructor called.... " << std::endl;
00014         pthread_mutex_init(&LASmutex_,NULL);
00015         pthread_cond_init(&more_,NULL);
00016         pthread_cond_init(&less_,NULL);
00017  
00018   
00019 }
00020 
00021 xmas2dqm::wse::ToDqm::~ToDqm()
00022 {
00023 
00024         //The implementation has detected an attempt to destroy the object referenced by mutex while 
00025         //it is locked or referenced (for example, while being used in a pthread_cond_timedwait() or pthread_cond_wait()) by another thread.
00026         
00027         //pthread_mutex_unlock(&mymutex_);
00028          //pthread_mutex_destroy(&mymutex_);
00029 }
00030 
00031 
00032 void  xmas2dqm::wse::ToDqm::digest
00033         (
00034                 const std::string& flashListName, 
00035                 const std::string& originator, 
00036                 const std::string& tag, 
00037                 /*xdata::Table::Reference table*/
00038                 xdata::Table *table
00039         ) 
00040         throw (xmas2dqm::wse::exception::Exception)
00041 {
00042 
00043         std::cout << "inside digest...." << std::endl;
00044         
00045         std::map<std::string, std::string, std::less<std::string> >::iterator i;
00046         
00047         //std::cout<< "ToDQM->digest : before BSem_.take();" << std::endl;
00048         //BSem_.take();
00049         //acquire the mutex - protect access to the queue
00050         //pthread_mutex_lock(&mymutex_);
00051    
00052         //check if the queue is full and wait (a signal that informs that an element has been poped)
00053         // until there is 'space' in the queue    
00054         //while (QTable_.size() >= Qsize_max)
00055         //{
00056                 //pthread_cond_wait(&less_, &mymutex_);
00057         //}
00058         
00059         //push new element to the queue of LAS data
00060         //QTable_.push(table);
00061         MemoryTable_.push(table);
00062         
00063         //MemoryTable_.push(mtable);
00064         
00065         //std::cout << "ToDQM->digest : Queue size = " << QTable_.size() << std::endl;
00066         
00067         //std::cout<< "ToDQM->digest : before BSem_.give();" << std::endl;
00068         
00069         //signal that a new element has been inserted
00070         //pthread_cond_signal(&more_);
00071 
00072         //allow access to the queue
00073         //pthread_mutex_unlock(&mymutex_);
00074         //BSem_.give();
00075         
00076         messageCount_++;
00077          
00078 }
00079 
00080 void xmas2dqm::wse::ToDqm::free_memory()
00081 {       
00082         std::cout << "free_memory: before MemoryTable.front()" << std::endl;
00083         
00084         xdata::Table * temp = MemoryTable_.front();
00085         delete temp;
00086         
00087         //MemoryTable_.front()->xdata::Table::~Table() ;
00088         
00089         //MemoryTable_.front()->clear();
00090         
00091         
00092         std::cout << "free_memory: before MemoryTable.pop()" << std::endl;
00093         MemoryTable_.pop();
00094         
00095         std::cout << "free_memory: returning...." << std::endl;
00096 }
00097