source: flair-src/trunk/lib/FlairCore/src/unexported/SharedMem_impl.h@ 234

Last change on this file since 234 was 203, checked in by Bayard Gildas, 6 years ago

Added timeout on SharedMem Read

File size: 1.2 KB
Line 
1// %flair:license{
2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
4// %flair:license}
5/*!
6 * \file SharedMem_impl.h
7 * \brief Class defining a shared memory
8 * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253
9 * \date 2014/02/10
10 * \version 4.0
11 */
12
13#ifndef SHAREDMEM_IMPL_H
14#define SHAREDMEM_IMPL_H
15
16#include <string>
17
18#ifdef __XENO__
19#include <native/heap.h>
20#endif
21
22#include <Semaphore.h>
23
24#include <SharedMem.h>
25
26/*! \class SharedMem_impl
27* \brief Class defining a shared memory
28*
29*/
30
31class SharedMem_impl {
32public:
33 SharedMem_impl(const flair::core::SharedMem *self, std::string name,
34 size_t size, flair::core::SharedMem::Type &type);
35 ~SharedMem_impl();
36
37 void Write(const char *buf, size_t size);
38 bool Read(char *buf, size_t size, flair::core::Time nsTimeout);
39 void ReaderReady();
40
41private:
42 const flair::core::SharedMem *self;
43 flair::core::SharedMem::Type type;
44 size_t size;
45 char *mem_segment;
46 flair::core::Semaphore sem,sem_producer,sem_consumer;
47#ifdef __XENO__
48 RT_HEAP heap;
49 bool heap_binded;
50#else
51 int fd;
52 std::string shm_name;
53#endif
54};
55
56#endif // SHAREDMEM_IMPL_H
Note: See TracBrowser for help on using the repository browser.