LCOV - code coverage report
Current view: top level - fsfw/ipc - MutexIF.h (source / functions) Hit Total Coverage
Test: fsfw-tests_coverage.info Lines: 1 1 100.0 %
Date: 2023-12-12 13:11:03 Functions: 1 2 50.0 %

          Line data    Source code
       1             : #ifndef FRAMEWORK_IPC_MUTEXIF_H_
       2             : #define FRAMEWORK_IPC_MUTEXIF_H_
       3             : 
       4             : #include "../returnvalues/returnvalue.h"
       5             : 
       6             : /**
       7             :  * @brief Common interface for OS Mutex objects which provide MUTual EXclusion.
       8             :  * @details https://en.wikipedia.org/wiki/Lock_(computer_science)
       9             :  * @ingroup osal
      10             :  * @ingroup interface
      11             :  */
      12             : class MutexIF {
      13             :  public:
      14             :   /**
      15             :    * Different types of timeout for the mutex lock.
      16             :    */
      17             :   enum class TimeoutType {
      18             :     POLLING,  //!< If mutex is not available, return immediately
      19             :     WAITING,  //!< Wait a specified time for the mutex to become available
      20             :     BLOCKING  //!< Block indefinitely until the mutex becomes available.
      21             :   };
      22             : 
      23             :   /**
      24             :    * Lock the mutex. The timeout value will only be used for
      25             :    * TimeoutType::WAITING
      26             :    * @param timeoutType
      27             :    * @param timeoutMs
      28             :    * @return
      29             :    */
      30             :   virtual ReturnValue_t lockMutex(TimeoutType timeoutType = TimeoutType::BLOCKING,
      31             :                                   uint32_t timeoutMs = 0) = 0;
      32             :   virtual ReturnValue_t unlockMutex() = 0;
      33             : 
      34             :   static const uint8_t INTERFACE_ID = CLASS_ID::MUTEX_IF;
      35             :   /**
      36             :    * The system lacked the necessary resources (other than memory) to initialize another mutex.
      37             :    */
      38             :   static const ReturnValue_t NOT_ENOUGH_RESOURCES = MAKE_RETURN_CODE(1);
      39             :   /**
      40             :    * Insufficient memory to create or init Mutex
      41             :    */
      42             :   static const ReturnValue_t INSUFFICIENT_MEMORY = MAKE_RETURN_CODE(2);
      43             :   /**
      44             :    * Caller does not have enough or right privilege
      45             :    */
      46             :   static const ReturnValue_t NO_PRIVILEGE = MAKE_RETURN_CODE(3);
      47             :   /**
      48             :    * Wrong Attribute Setting
      49             :    */
      50             :   static const ReturnValue_t WRONG_ATTRIBUTE_SETTING = MAKE_RETURN_CODE(4);
      51             :   /**
      52             :    * The mutex is already locked
      53             :    */
      54             :   static const ReturnValue_t MUTEX_ALREADY_LOCKED = MAKE_RETURN_CODE(5);
      55             :   /**
      56             :    * Mutex object not found
      57             :    */
      58             :   static const ReturnValue_t MUTEX_NOT_FOUND = MAKE_RETURN_CODE(6);
      59             :   /**
      60             :    * Mutex could not be locked because max amount of recursive locks
      61             :    */
      62             :   static const ReturnValue_t MUTEX_MAX_LOCKS = MAKE_RETURN_CODE(7);
      63             :   /**
      64             :    * The current thread already owns this mutex
      65             :    */
      66             :   static const ReturnValue_t CURR_THREAD_ALREADY_OWNS_MUTEX = MAKE_RETURN_CODE(8);
      67             :   /**
      68             :    * Current thread does not own this mutex
      69             :    */
      70             :   static const ReturnValue_t CURR_THREAD_DOES_NOT_OWN_MUTEX = MAKE_RETURN_CODE(9);
      71             :   /**
      72             :    * The Mutex could not be blocked before timeout
      73             :    */
      74             :   static const ReturnValue_t MUTEX_TIMEOUT = MAKE_RETURN_CODE(10);
      75             :   /**
      76             :    * Invalid Mutex ID
      77             :    */
      78             :   static const ReturnValue_t MUTEX_INVALID_ID = MAKE_RETURN_CODE(11);
      79             :   /**
      80             :    * Mutex destroyed while waiting
      81             :    */
      82             :   static const ReturnValue_t MUTEX_DESTROYED_WHILE_WAITING = MAKE_RETURN_CODE(12);
      83             : 
      84          24 :   virtual ~MutexIF() {}
      85             : };
      86             : 
      87             : #endif /* FRAMEWORK_IPC_MUTEXIF_H_ */

Generated by: LCOV version 1.14

Impressum Datenschutz