mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-28 11:47:48 +02:00
NTP sync in separate thread
This commit is contained in:
parent
d7081c5f23
commit
8a549b83a2
3 changed files with 110 additions and 11 deletions
|
@ -2,6 +2,10 @@
|
|||
#define TIMESTAMP_H__
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <boost/asio.hpp>
|
||||
|
||||
namespace i2p
|
||||
{
|
||||
|
@ -11,7 +15,30 @@ namespace util
|
|||
uint32_t GetHoursSinceEpoch ();
|
||||
uint64_t GetSecondsSinceEpoch ();
|
||||
|
||||
void RequestNTPTimeSync ();
|
||||
class NTPTimeSync
|
||||
{
|
||||
public:
|
||||
|
||||
NTPTimeSync ();
|
||||
~NTPTimeSync ();
|
||||
|
||||
void Start ();
|
||||
void Stop ();
|
||||
|
||||
private:
|
||||
|
||||
void Run ();
|
||||
void Sync ();
|
||||
|
||||
private:
|
||||
|
||||
bool m_IsRunning;
|
||||
std::unique_ptr<std::thread> m_Thread;
|
||||
boost::asio::io_service m_Service;
|
||||
boost::asio::deadline_timer m_Timer;
|
||||
int m_SyncInterval;
|
||||
std::vector<std::string> m_NTPServersList;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue