/*
{{copyright}}
*/

/*
{{version}}
*/

/*
{{license}}
*/

#pragma once

#include <FreeRTOSHeaders.h>
#include <sdi_toolBox/dateTime/iPause.h>

namespace sdi_uToolBox::dateTime::FreeRTOS
{
//--------------------------------------------------------------
/**
 * @brief FreeRTOS pause implementation.
 *
 * Implements IPause to provide a non-blocking pause using vTaskDelay
 * in FreeRTOS environments.
 */
class Pause : public sdi_toolBox::dateTime::IPause
{
  public:
  Pause()                                = default;     // Default constructor
  ~Pause()                               = default;     // Default destructor
  Pause(const Pause &obj)                = default;     // Copy constructor
  Pause(Pause &&obj) noexcept            = default;     // Move constructor
  Pause &operator=(const Pause &obj)     = default;     // Copy assignment operator
  Pause &operator=(Pause &&obj) noexcept = default;     // Move assignment operator

  explicit Pause(const Duration &duration);     // Constructor

  /**
   * @brief Pause execution for the specified duration using vTaskDelay.
   * @param duration Duration of the pause.
   */
  void wait(const Duration &duration) const override;
};
//--------------------------------------------------------------
/* Constructor */
inline Pause::Pause(const Duration &duration)
{
  wait(duration);
}
//--------------------------------------------------------------
/* Pause execution for the specified duration */
inline void Pause::wait(const Duration &duration) const
{
  vTaskDelay(pdMS_TO_TICKS(duration.count()));
}
//--------------------------------------------------------------
}     // namespace sdi_uToolBox::dateTime::FreeRTOS
