Implement use of Inventory API
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
#include <iostream>
|
||||
|
||||
#include <chrono>
|
||||
#include "Util.h"
|
||||
#include "Timer.h"
|
||||
@@ -8,12 +10,14 @@ namespace Util {
|
||||
|
||||
Timer::Timer() :
|
||||
m_run(false),
|
||||
m_aborted(false),
|
||||
m_identifier(CreateRandomString(10))
|
||||
{
|
||||
}
|
||||
|
||||
Timer::~Timer()
|
||||
{
|
||||
Abort();
|
||||
Wait();
|
||||
}
|
||||
|
||||
@@ -57,6 +61,17 @@ void Timer::Stop()
|
||||
m_run.store(false, std::memory_order_release);
|
||||
}
|
||||
|
||||
void Timer::Abort()
|
||||
{
|
||||
std::cout << "Timer::Abort()" << std::endl;
|
||||
m_run.store(false, std::memory_order_release);
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
m_aborted = true;
|
||||
}
|
||||
m_conditionVariable.notify_all();
|
||||
}
|
||||
|
||||
bool Timer::IsRunning() const noexcept
|
||||
{
|
||||
return (m_run.load(std::memory_order_acquire) && m_thread.joinable());
|
||||
|
||||
Reference in New Issue
Block a user