YARP
Yet Another Robot Platform
ShmemInputStream.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef YARP_SHMEM_SHMEMINPUTSTREAM_H
8 #define YARP_SHMEM_SHMEMINPUTSTREAM_H
9 
10 #include "ShmemTypes.h"
11 
12 #include <yarp/os/InputStream.h>
13 #include <yarp/os/Thread.h>
14 #include <yarp/os/Time.h>
15 
16 #include <mutex>
17 
18 #include <ace/config.h>
19 #include <ace/Mutex.h>
20 #include <ace/Process_Mutex.h>
21 #include <ace/SOCK_Stream.h>
22 #include <ace/SOCK_Acceptor.h>
23 #include <ace/SOCK_Connector.h>
24 #include <ace/Log_Msg.h>
25 #if defined(ACE_LACKS_SYSV_SHMEM)
26 #include <ace/Shared_Memory_MM.h>
27 #else
28 #include <ace/Shared_Memory_SV.h>
29 #endif
30 // In one the ACE headers there is a definition of "main" for WIN32
31 # ifdef main
32 # undef main
33 # endif
34 
35 
36 
38 {
39 public:
42 
43  bool isOk() const;
44  bool open(int port, ACE_SOCK_Stream* pSock, int size = SHMEM_DEFAULT_SIZE);
46  void close();
47 
48 protected:
49  int read(char* data, int len);
50  bool Resize();
51  bool m_bOpen;
52 
54  int m_Port;
55 
56 #if defined(_ACE_USE_SV_SEM)
57  ACE_Mutex* m_pAccessMutex;
58  ACE_Mutex* m_pWaitDataMutex;
59 #else
60  ACE_Process_Mutex* m_pAccessMutex;
61  ACE_Process_Mutex* m_pWaitDataMutex;
62 #endif
63 
65 
66  ACE_Shared_Memory* m_pMap;
67  char* m_pData;
69 
70  ACE_SOCK_Stream* m_pSock;
71 };
72 
73 #endif
#define SHMEM_DEFAULT_SIZE
Definition: ShmemTypes.h:10
ACE_SOCK_Stream * m_pSock
yarp::conf::ssize_t read(yarp::os::Bytes &b)
ACE_Shared_Memory * m_pMap
ACE_Process_Mutex * m_pWaitDataMutex
ShmemHeader_t * m_pHeader
bool open(int port, ACE_SOCK_Stream *pSock, int size=4096)
std::mutex m_ReadSerializerMutex
ACE_Process_Mutex * m_pAccessMutex
A simple abstraction for a block of bytes.
Definition: Bytes.h:25
::ssize_t ssize_t
Definition: numeric.h:86