CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CommandQueue.cc
Go to the documentation of this file.
1 //
3 // CommandQueue.cc
4 // -------
5 //
6 // Created on: Dec 13, 2011
7 // Andrei Spataru : aspataru@cern.ch
9 
11 
12 #include <iostream>
13 
14 using namespace evf::rb_statemachine;
15 
16 using std::cout;
17 using std::endl;
18 
20  sem_init(&lock_, 0, 1);
21  // commands semaphore initialized to 0
22  // no commands on the queue initially
23  sem_init(&commandsSem_, 0, 0);
24 }
25 
27 }
28 
30  lock();
31  eventQueue_.push(evType);
32  sem_post(&commandsSem_);
33  unlock();
34 }
35 
37  sem_wait(&commandsSem_);
38  EventPtr eventPtr;
39 
40  lock();
41  eventPtr = eventQueue_.front();
42  eventQueue_.pop();
43  unlock();
44 
45  return eventPtr;
46 }
47 
49  while (0 != sem_wait(&lock_)) {
50  cout << "SMEventScheduler: cannot obtain lock!" << endl;
51  sleep(1);
52  }
53 }
54 
56  sem_post(&lock_);
57 }
boost::shared_ptr< boost::statechart::event_base > EventPtr
Definition: CommandQueue.h:23
void sleep(Duration_t)
Definition: Utils.h:163
std::queue< EventPtr > eventQueue_
Definition: CommandQueue.h:53
tuple cout
Definition: gather_cfg.py:121