38 lines
722 B
C++
38 lines
722 B
C++
#pragma once
|
|
|
|
#include "server/sparkd/orderman/events/TimeChange.h"
|
|
#include "server/sparkd/orderman/utils/orderman_utils.h"
|
|
|
|
#include "lib/utils/bts_chrono.h"
|
|
|
|
namespace bts {
|
|
namespace orderman {
|
|
|
|
class TimeSource
|
|
{
|
|
public:
|
|
|
|
TimeSource() : time_change_signal([](auto){}),_last() {}
|
|
|
|
// out
|
|
std::function<void(event::TimeChange const&)> time_change_signal;
|
|
|
|
void do_work() {
|
|
auto now = Timer::now();
|
|
if (ms_diff(now,_last) > 10) {
|
|
_last = now;
|
|
auto change = event::TimeChange {
|
|
Timer::now(),
|
|
to<OrderTimeStamp> (datetime::FIX_timestamp(datetime::now()))
|
|
};
|
|
time_change_signal(change);
|
|
}
|
|
}
|
|
|
|
private:
|
|
TimeStamp _last;
|
|
};
|
|
|
|
}}
|
|
|