Implement use of Inventory API

This commit is contained in:
2019-04-23 11:41:34 +02:00
parent ea71693886
commit 5724bd45a7
9 changed files with 184 additions and 62 deletions
+15
View File
@@ -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());