Last change
on this file since 324 was 238, checked in by Bayard Gildas, 6 years ago |
correction sémaphore. bloquant tout ça...
|
File size:
1.4 KB
|
Rev | Line | |
---|
[117] | 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 Semaphore.h
|
---|
| 7 | * \brief Class defining a semaphore
|
---|
| 8 | * \author Thomas Fuhrmann, Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
| 9 | * \date 2016/11/16
|
---|
| 10 | * \version 1.0
|
---|
| 11 | */
|
---|
| 12 |
|
---|
| 13 | #ifndef SEMAPHORE_H
|
---|
| 14 | #define SEMAPHORE_H
|
---|
| 15 |
|
---|
| 16 | #include <Object.h>
|
---|
| 17 |
|
---|
| 18 | class Semaphore_impl;
|
---|
| 19 | class ConditionVariable_impl;
|
---|
| 20 |
|
---|
| 21 | namespace flair {
|
---|
| 22 | namespace core {
|
---|
| 23 |
|
---|
| 24 | /*! \class Semaphore
|
---|
| 25 | *
|
---|
| 26 | * \brief Class defining a semaphore
|
---|
| 27 | *
|
---|
| 28 | */
|
---|
| 29 | class Semaphore : public Object {
|
---|
| 30 | friend class ::ConditionVariable_impl;
|
---|
| 31 |
|
---|
| 32 | public:
|
---|
[238] | 33 | enum class Type { anonymous, named };
|
---|
[117] | 34 | /*!
|
---|
| 35 | * \brief Constructor
|
---|
| 36 | *
|
---|
| 37 | * Construct a semaphore.
|
---|
| 38 | *
|
---|
| 39 | * \param parent parent
|
---|
| 40 | * \param name name
|
---|
| 41 | */
|
---|
[238] | 42 | Semaphore(const Object *parent, uint32_t initialValue, std::string name = "", Type type=Type::anonymous);
|
---|
[117] | 43 |
|
---|
| 44 | /*!
|
---|
| 45 | * \brief Destructor
|
---|
| 46 | *
|
---|
| 47 | */
|
---|
| 48 | ~Semaphore();
|
---|
| 49 |
|
---|
| 50 | /*!
|
---|
[203] | 51 | * \brief TryGetSemaphore
|
---|
| 52 | *
|
---|
| 53 | * Lock the semaphore. If not possible immediately returns false
|
---|
| 54 | *
|
---|
| 55 | */
|
---|
| 56 | bool TryGetSemaphore() const;
|
---|
| 57 |
|
---|
| 58 | /*!
|
---|
[117] | 59 | * \brief GetSemaphore
|
---|
| 60 | *
|
---|
| 61 | * Lock the semaphore.
|
---|
[126] | 62 | *
|
---|
| 63 | * \param timeout The timeout, in nanoseconds.
|
---|
[117] | 64 | */
|
---|
[126] | 65 | bool GetSemaphore(Time timeout = TIME_INFINITE) const;
|
---|
[117] | 66 |
|
---|
| 67 | /*!
|
---|
| 68 | * \brief ReleaseSemaphore
|
---|
| 69 | *
|
---|
| 70 | * Unlock the semaphore.
|
---|
| 71 | *
|
---|
| 72 | */
|
---|
[126] | 73 | bool ReleaseSemaphore(void) const;
|
---|
[117] | 74 |
|
---|
| 75 | private:
|
---|
| 76 | class Semaphore_impl *pimpl_;
|
---|
[238] | 77 | Type type;
|
---|
[117] | 78 | };
|
---|
| 79 |
|
---|
| 80 | } // end namespace core
|
---|
| 81 | } // end namespace flair
|
---|
| 82 |
|
---|
| 83 | #endif // SEMAPHORE_H
|
---|
Note:
See
TracBrowser
for help on using the repository browser.