ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthenaInterprocess
src
IdentifiedSharedQueue.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
AthenaInterprocess/IdentifiedSharedQueue.h
"
6
7
#include <boost/interprocess/ipc/message_queue.hpp>
8
9
#include <sstream>
10
11
using namespace
boost::interprocess
;
12
13
14
//const std::size_t MAX_MSG_SIZE = 4096;
15
16
namespace
AthenaInterprocess
{
17
18
//- construction/destruction -------------------------------------------------
19
IdentifiedSharedQueue::IdentifiedSharedQueue
() :
SharedQueue
()
20
{
21
/* empty */
22
}
23
24
IdentifiedSharedQueue::IdentifiedSharedQueue
(
const
std::string&
name
,
int
max_msg, std::size_t max_size,
bool
do_unlink ) :
25
SharedQueue
(
name
, max_msg, max_size, do_unlink )
26
{
27
/* empty */
28
}
29
30
//- public member functions --------------------------------------------------
31
inline
std::string
add_pid
(
const
std::string& buf )
32
{
33
std::ostringstream s;
34
s << (long)getpid() <<
'\0'
<< buf;
35
return
s.str();
36
}
37
38
bool
IdentifiedSharedQueue::try_send
(
const
std::string& buf )
39
{
40
return
this->
SharedQueue::try_send
(
add_pid
( buf ) );
41
}
42
43
bool
IdentifiedSharedQueue::send
(
const
std::string& buf )
44
{
45
return
this->
SharedQueue::send
(
add_pid
( buf ) );
46
}
47
48
inline
std::string
get_pid
(
const
std::string& buf,
pid_t
&pid )
49
{
50
std::istringstream s( buf );
51
long
id
= -1;
52
s >> id;
53
pid = (
pid_t
)
id
;
54
std::string::size_type pos = s.tellg();
55
if
( (pos+1) <= buf.size() )
56
return
buf.substr( pos+1 );
57
return
""
;
58
}
59
60
61
std::string
IdentifiedSharedQueue::try_receive
()
62
{
63
pid_t
pid;
64
return
try_receive
( pid );
65
}
66
67
std::string
IdentifiedSharedQueue::try_receive
(
pid_t
&
id
)
68
{
69
const
std::string& buf = this->
SharedQueue::try_receive
();
70
return
get_pid
( buf,
id
);
71
}
72
73
std::string
IdentifiedSharedQueue::receive
()
74
{
75
pid_t
pid;
76
return
receive
( pid );
77
}
78
79
std::string
IdentifiedSharedQueue::receive
(
pid_t
&
id
)
80
{
81
const
std::string& buf = this->
SharedQueue::receive
();
82
return
get_pid
( buf,
id
);
83
}
84
85
}
// namespace AthenaInterprocess
pid_t
int32_t pid_t
Definition
FPGATrackSimTypes.h:19
IdentifiedSharedQueue.h
AthenaInterprocess::IdentifiedSharedQueue::IdentifiedSharedQueue
IdentifiedSharedQueue()
Definition
IdentifiedSharedQueue.cxx:19
AthenaInterprocess::IdentifiedSharedQueue::receive
virtual std::string receive()
Definition
IdentifiedSharedQueue.cxx:73
AthenaInterprocess::IdentifiedSharedQueue::send
virtual bool send(const std::string &)
Definition
IdentifiedSharedQueue.cxx:43
AthenaInterprocess::IdentifiedSharedQueue::try_send
virtual bool try_send(const std::string &)
Definition
IdentifiedSharedQueue.cxx:38
AthenaInterprocess::IdentifiedSharedQueue::try_receive
virtual std::string try_receive()
Definition
IdentifiedSharedQueue.cxx:61
AthenaInterprocess::SharedQueue::name
std::string name() const
Definition
SharedQueue.cxx:78
AthenaInterprocess::SharedQueue::SharedQueue
SharedQueue()
Definition
SharedQueue.cxx:16
AthenaInterprocess::SharedQueue::try_receive
virtual std::string try_receive()
Definition
SharedQueue.cxx:140
AthenaInterprocess::SharedQueue::try_send
virtual bool try_send(const std::string &)
Definition
SharedQueue.cxx:102
AthenaInterprocess::SharedQueue::receive
virtual std::string receive()
Definition
SharedQueue.cxx:145
AthenaInterprocess::SharedQueue::send
virtual bool send(const std::string &)
Definition
SharedQueue.cxx:107
AthenaInterprocess
Definition
FdsRegistry.h:11
AthenaInterprocess::add_pid
std::string add_pid(const std::string &buf)
Definition
IdentifiedSharedQueue.cxx:31
AthenaInterprocess::get_pid
std::string get_pid(const std::string &buf, pid_t &pid)
Definition
IdentifiedSharedQueue.cxx:48
boost::interprocess
Definition
AthenaSharedMemoryTool.h:27
Generated on
for ATLAS Offline Software by
1.17.0