CMS 3D CMS Logo

WriteBuffer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: FWCore/SharedMemory
4 // Class : WriteBuffer
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Original Author: Chris Jones
10 // Created: 21/01/2020
11 //
12 
13 // system include files
14 
15 // user include files
17 
18 //
19 // constants, enums and typedefs
20 //
21 using namespace edm::shared_memory;
22 
23 //
24 // static data member definitions
25 //
26 
27 //
28 // constructors and destructor
29 //
30 
32  if (sm_) {
33  sm_->destroy<char>(buffer_names::kBuffer);
34  sm_.reset();
36  }
37 }
38 //
39 // member functions
40 //
41 void WriteBuffer::growBuffer(std::size_t iLength) {
42  int newBuffer = (bufferInfo_->index_ + 1) % 2;
43  if (sm_) {
44  sm_->destroy<char>(buffer_names::kBuffer);
45  sm_.reset();
47  }
48  sm_ = std::make_unique<boost::interprocess::managed_shared_memory>(
49  boost::interprocess::open_or_create, bufferNames_[newBuffer].c_str(), iLength + 1024);
50  assert(sm_.get());
51  bufferSize_ = iLength;
52  bufferInfo_->index_ = newBuffer;
54  buffer_ = sm_->construct<char>(buffer_names::kBuffer)[iLength](0);
55  assert(buffer_);
56 }
57 
58 //
59 // const member functions
60 //
61 
62 //
63 // static member functions
64 //
constexpr char const *const kBuffer
Definition: buffer_names.h:29
void growBuffer(std::size_t iLength)
Definition: WriteBuffer.cc:41
std::array< std::string, 2 > bufferNames_
Definition: WriteBuffer.h:71
def remove(d, key, TELL=False)
Definition: MatrixUtil.py:212
std::unique_ptr< boost::interprocess::managed_shared_memory > sm_
Definition: WriteBuffer.h:72