FWCore
SharedMemory
interface
WriteBuffer.h
Go to the documentation of this file.
1
#ifndef FWCore_SharedMemory_WriteBuffer_h
2
#define FWCore_SharedMemory_WriteBuffer_h
3
// -*- C++ -*-
4
//
5
// Package: FWCore/SharedMemory
6
// Class : WriteBuffer
7
//
17
//
18
// Original Author: Chris Jones
19
// Created: 21/01/2020
20
//
21
22
// system include files
23
#include <array>
24
#include <memory>
25
#include <string>
26
#include <cassert>
27
#include <algorithm>
28
#include "boost/interprocess/managed_shared_memory.hpp"
29
30
// user include files
31
#include "
FWCore/SharedMemory/interface/buffer_names.h
"
32
#include "
FWCore/SharedMemory/interface/BufferInfo.h
"
33
34
// forward declarations
35
36
namespace
edm::shared_memory
{
37
class
WriteBuffer
{
38
public
:
43
WriteBuffer
(
std::string
const
& iUniqueName,
BufferInfo
* iBufferInfo)
44
:
bufferSize_
{0},
buffer_
{
nullptr
},
bufferInfo_
{iBufferInfo} {
45
bufferNames_
[0] = iUniqueName +
buffer_names::kBuffer0
;
46
bufferNames_
[1] = iUniqueName +
buffer_names::kBuffer1
;
47
assert
(
bufferInfo_
);
48
}
49
WriteBuffer
(
const
WriteBuffer
&) =
delete
;
50
const
WriteBuffer
&
operator=
(
const
WriteBuffer
&) =
delete
;
51
WriteBuffer
(
WriteBuffer
&&) =
delete
;
52
const
WriteBuffer
&
operator=
(
WriteBuffer
&&) =
delete
;
53
54
~WriteBuffer
();
55
56
// ---------- member functions ---------------------------
57
void
copyToBuffer
(
const
char
* iStart, std::size_t iLength) {
58
if
(iLength >
bufferSize_
) {
59
growBuffer
(iLength);
60
}
61
std::copy
(iStart, iStart + iLength,
buffer_
);
62
}
63
64
private
:
65
void
growBuffer
(std::size_t iLength);
66
67
// ---------- member data --------------------------------
68
std::size_t
bufferSize_
;
69
char
*
buffer_
;
70
BufferInfo
*
bufferInfo_
;
71
std::array<std::string, 2>
bufferNames_
;
72
std::unique_ptr<boost::interprocess::managed_shared_memory>
sm_
;
73
};
74
}
// namespace edm::shared_memory
75
76
#endif
edm::shared_memory::WriteBuffer::growBuffer
void growBuffer(std::size_t iLength)
Definition:
WriteBuffer.cc:41
BufferInfo.h
filterCSVwithJSON.copy
copy
Definition:
filterCSVwithJSON.py:36
edm::shared_memory::buffer_names::kBuffer0
constexpr char const *const kBuffer0
Definition:
buffer_names.h:30
WriteBuffer
cms::cuda::assert
assert(be >=bs)
edm::shared_memory::WriteBuffer::operator=
const WriteBuffer & operator=(const WriteBuffer &)=delete
edm::shared_memory::WriteBuffer
Definition:
WriteBuffer.h:37
edm::shared_memory::BufferInfo
Definition:
BufferInfo.h:27
edm::shared_memory::WriteBuffer::bufferNames_
std::array< std::string, 2 > bufferNames_
Definition:
WriteBuffer.h:71
edm::shared_memory::WriteBuffer::WriteBuffer
WriteBuffer(std::string const &iUniqueName, BufferInfo *iBufferInfo)
Definition:
WriteBuffer.h:43
edm::shared_memory::WriteBuffer::bufferSize_
std::size_t bufferSize_
Definition:
WriteBuffer.h:68
buffer_names.h
edm::shared_memory::WriteBuffer::copyToBuffer
void copyToBuffer(const char *iStart, std::size_t iLength)
Definition:
WriteBuffer.h:57
edm::shared_memory
Definition:
buffer_names.h:27
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
edm::shared_memory::WriteBuffer::sm_
std::unique_ptr< boost::interprocess::managed_shared_memory > sm_
Definition:
WriteBuffer.h:72
edm::shared_memory::WriteBuffer::buffer_
char * buffer_
Definition:
WriteBuffer.h:69
edm::shared_memory::buffer_names::kBuffer1
constexpr char const *const kBuffer1
Definition:
buffer_names.h:31
edm::shared_memory::WriteBuffer::bufferInfo_
BufferInfo * bufferInfo_
Definition:
WriteBuffer.h:70
edm::shared_memory::WriteBuffer::~WriteBuffer
~WriteBuffer()
Definition:
WriteBuffer.cc:31
Generated for CMSSW Reference Manual by
1.8.16