source: flair-src/trunk/lib/FlairCore/src/SharedMem.h

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

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

File size: 1.7 KB
RevLine 
[2]1// %flair:license{
[15]2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
[2]4// %flair:license}
5/*!
6 * \file SharedMem.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_H
14#define SHAREDMEM_H
15
16#include <Object.h>
17#include <semaphore.h>
18
19class SharedMem_impl;
20
[15]21namespace flair {
22namespace core {
[2]23
[15]24/*! \class SharedMem
25*
26* \brief Class defining a shared memory
27*
28* Shared memory is identified by its name so it can be accessed
[203]29* by another process using its name.
[15]30*/
[2]31
[15]32class SharedMem : public Object {
33public:
[149]34 enum class Type { mutex, producerConsumer };
[15]35 /*!
36 * \brief Constructor
37 *
38 * Construct a shared memory object
39 *
40 * \param parent parent
41 * \param name name
[238]42 * \param size size of the shared memory:w
43 *
44 * \param type mutex or producerConsumer. Mutex type is for symmetrical use (default)
[15]45 */
[149]46 SharedMem(const Object *parent, std::string name, size_t size, Type type=Type::mutex);
[2]47
[15]48 /*!
49 * \brief Destructor
50 *
51 */
52 ~SharedMem();
[2]53
[15]54 /*!
55 * \brief Write
56 *
57 * \param buf input buffer to write to memory
58 * \param size buffer size
59 */
60 void Write(const char *buf, size_t size);
[2]61
[15]62 /*!
63 * \brief Read
64 *
65 * \param buf output buffer to write from memory
66 * \param size buffer size
67 */
[203]68 bool Read(char *buf, size_t size, Time nsTimeout=TIME_INFINITE) const;
[2]69
[149]70
71 /*!
[203]72 * \brief This function should be called when reader is ready (in case of a SharedMem of type producerConsumer)
[149]73 */
74 void ReaderReady();
[15]75private:
76 SharedMem_impl *pimpl_;
[149]77 Type type;
[15]78};
[2]79
80} // end namespace core
81} // end namespace flair
82
83#endif // SHAREDMEM_H
Note: See TracBrowser for help on using the repository browser.