Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
input_buffer_collector.hh
Go to the documentation of this file.
1#ifndef DATAQUEUE_FRAMEFACTORY_INPUT_BUFFER_COLLECTOR_HH
2#define DATAQUEUE_FRAMEFACTORY_INPUT_BUFFER_COLLECTOR_HH
3
5
6#include <boost/thread/mutex.hpp>
7#include <deque>
8#include <iostream>
9
10/**
11 * \author cpellegrino
12 */
13
15{
16 typedef std::deque<CLBDataGram*> datagram_collector_t;
17
19
20 boost::mutex m_mutex;
21
24
25 public:
26
28 {
29 static InBufferCollector istance;
30
31 return istance;
32 }
33
35 {
36 CLBDataGram* temp;
37
38 boost::mutex::scoped_lock lock(m_mutex);
39
40 if (m_collector.empty()) {
41 temp = new CLBDataGram;
42 } else {
43 temp = m_collector.back();
44
45 m_collector.pop_back();
46 temp->clear();
47 }
48
50 return temp;
51 }
52
54 {
55 boost::mutex::scoped_lock lock(m_mutex);
56
57 if (m_collector.size() > 40000)
58 {
59 delete p;
60 }
61 else
62 {
63 m_collector.push_back(p);
64 }
65 }
66
67};
68
69#endif // DATAQUEUE_FRAMEFACTORY_INPUT_BUFFER_COLLECTOR_HH
std::deque< CLBDataGram * > datagram_collector_t
void putDataGram(CLBDataGram *p)
static InBufferCollector & getCollector()
CLBDataGram * getEmptyDataGram()
datagram_collector_t m_collector
void chrono_reset(chronometrable &chr)