Main Page
Namespaces
Classes
Package Documentation
FWCore
SharedMemory
src
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
16
#include "
FWCore/SharedMemory/interface/WriteBuffer.h
"
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
31
WriteBuffer::~WriteBuffer
() {
32
if
(
sm_
) {
33
sm_
->destroy<
char
>(
buffer_names::kBuffer
);
34
sm_
.reset();
35
boost::interprocess::shared_memory_object::remove
(
bufferNames_
[
bufferInfo_
->
index_
].c_str());
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();
46
boost::interprocess::shared_memory_object::remove
(
bufferNames_
[
bufferInfo_
->
index_
].c_str());
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;
53
bufferInfo_
->
identifier_
=
bufferInfo_
->
identifier_
+ 1;
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
//
edm::shared_memory::buffer_names::kBuffer
constexpr char const *const kBuffer
Definition:
buffer_names.h:29
edm::shared_memory::WriteBuffer::~WriteBuffer
~WriteBuffer()
Definition:
WriteBuffer.cc:31
edm::shared_memory
Definition:
buffer_names.h:27
edm::shared_memory::WriteBuffer::growBuffer
void growBuffer(std::size_t iLength)
Definition:
WriteBuffer.cc:41
edm::shared_memory::WriteBuffer::bufferNames_
std::array< std::string, 2 > bufferNames_
Definition:
WriteBuffer.h:71
edm::shared_memory::BufferInfo::identifier_
int identifier_
Definition:
BufferInfo.h:28
edm::shared_memory::WriteBuffer::buffer_
char * buffer_
Definition:
WriteBuffer.h:69
edm::shared_memory::WriteBuffer::bufferSize_
std::size_t bufferSize_
Definition:
WriteBuffer.h:68
MatrixUtil.remove
def remove(d, key, TELL=False)
Definition:
MatrixUtil.py:212
edm::shared_memory::BufferInfo::index_
char index_
Definition:
BufferInfo.h:29
WriteBuffer.h
edm::shared_memory::WriteBuffer::bufferInfo_
BufferInfo * bufferInfo_
Definition:
WriteBuffer.h:70
edm::shared_memory::WriteBuffer::sm_
std::unique_ptr< boost::interprocess::managed_shared_memory > sm_
Definition:
WriteBuffer.h:72
Generated for CMSSW Reference Manual by
1.8.11