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

Last change on this file was 238, checked in by Bayard Gildas, 4 years ago

correction sémaphore. bloquant tout ça...

File size: 1.3 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; //for mutex type shared memory
47  flair::core::Semaphore *sem_producer,*sem_consumer; //sem_[produc|consum]er meaning = is [produc|consum]er ready?
48#ifdef __XENO__
49  RT_HEAP heap;
50  bool heap_binded;
51#else
52  int fd;
53  std::string shm_name;
54#endif
55};
56
57#endif // SHAREDMEM_IMPL_H
Note: See TracBrowser for help on using the repository browser.