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

Last change on this file since 187 was 149, checked in by Bayard Gildas, 4 years ago

SharedMem? in producerConsumer mode

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#include <native/mutex.h>
21#else
22#include <semaphore.h>
23#endif
24
25#include <SharedMem.h>
26
27/*! \class SharedMem_impl
28* \brief Class defining a shared memory
29*
30*/
31
32class SharedMem_impl {
33public:
34  SharedMem_impl(const flair::core::SharedMem *self, std::string name,
35                 size_t size, flair::core::SharedMem::Type &type);
36  ~SharedMem_impl();
37
38  void Write(const char *buf, size_t size);
39  void Read(char *buf, size_t size);
40  void ReaderReady();
41
42private:
43  const flair::core::SharedMem *self;
44  flair::core::SharedMem::Type type;
45  size_t size;
46  char *mem_segment;
47#ifdef __XENO__
48  RT_HEAP heap;
49  RT_MUTEX mutex;
50  bool heap_binded;
51  bool mutex_binded;
52#else
53  int fd;
54  sem_t *sem,*sem_producer,*sem_consumer;
55  std::string sem_name, shm_name;
56  std::string sem_name_producer,sem_name_consumer;
57#endif
58};
59
60#endif // SHAREDMEM_IMPL_H
Note: See TracBrowser for help on using the repository browser.