Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
EventFilter
ResourceBroker
src
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
10
#include "
EventFilter/ResourceBroker/interface/CommandQueue.h
"
11
12
#include <iostream>
13
14
using namespace
evf::rb_statemachine;
15
16
using
std::cout
;
17
using
std::endl;
18
19
CommandQueue::CommandQueue
() {
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
26
CommandQueue::~CommandQueue
() {
27
}
28
29
void
CommandQueue::enqEvent
(
EventPtr
evType) {
30
lock
();
31
eventQueue_
.push(evType);
32
sem_post(&
commandsSem_
);
33
unlock
();
34
}
35
36
EventPtr
CommandQueue::deqEvent
() {
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
48
void
CommandQueue::lock
() {
49
while
(0 != sem_wait(&
lock_
)) {
50
cout
<<
"SMEventScheduler: cannot obtain lock!"
<< endl;
51
sleep
(1);
52
}
53
}
54
55
void
CommandQueue::unlock
() {
56
sem_post(&
lock_
);
57
}
evf::rb_statemachine::CommandQueue::enqEvent
void enqEvent(EventPtr event)
Definition:
CommandQueue.cc:29
evf::rb_statemachine::CommandQueue::~CommandQueue
~CommandQueue()
Definition:
CommandQueue.cc:26
evf::rb_statemachine::EventPtr
boost::shared_ptr< boost::statechart::event_base > EventPtr
Definition:
CommandQueue.h:23
evf::rb_statemachine::CommandQueue::lock_
sem_t lock_
Definition:
CommandQueue.h:54
stor::utils::sleep
void sleep(Duration_t)
Definition:
Utils.h:163
evf::rb_statemachine::CommandQueue::commandsSem_
sem_t commandsSem_
Definition:
CommandQueue.h:56
CommandQueue.h
evf::rb_statemachine::CommandQueue::deqEvent
EventPtr deqEvent()
Definition:
CommandQueue.cc:36
evf::rb_statemachine::CommandQueue::lock
void lock()
Definition:
CommandQueue.cc:48
evf::rb_statemachine::CommandQueue::eventQueue_
std::queue< EventPtr > eventQueue_
Definition:
CommandQueue.h:53
evf::rb_statemachine::CommandQueue::CommandQueue
CommandQueue()
Definition:
CommandQueue.cc:19
gather_cfg.cout
tuple cout
Definition:
gather_cfg.py:121
evf::rb_statemachine::CommandQueue::unlock
void unlock()
Definition:
CommandQueue.cc:55
Generated for CMSSW Reference Manual by
1.8.5