Adds the sdi_toolBox library (temporary version)
This commit is contained in:
59
sdi_toolBox_1.0.x/toolBox/sdi_toolBox/dateTime/pause.h
Normal file
59
sdi_toolBox_1.0.x/toolBox/sdi_toolBox/dateTime/pause.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
{{copyright}}
|
||||
*/
|
||||
|
||||
/*
|
||||
{{version}}
|
||||
*/
|
||||
|
||||
/*
|
||||
{{license}}
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "iPause.h"
|
||||
|
||||
#include <thread>
|
||||
|
||||
namespace sdi_toolBox::dateTime
|
||||
{
|
||||
//--------------------------------------------------------------
|
||||
/**
|
||||
* @brief Standard pause implementation.
|
||||
*
|
||||
* Implements IPause to provide a blocking pause using standard C++ mechanisms.
|
||||
* The actual delay is performed using std::this_thread::sleep_for.
|
||||
*/
|
||||
class Pause : public 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.
|
||||
* @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
|
||||
{
|
||||
std::this_thread::sleep_for(duration);
|
||||
}
|
||||
//--------------------------------------------------------------
|
||||
} // namespace sdi_toolBox::dateTime
|
||||
Reference in New Issue
Block a user