12345678910111213141516171819202122232425262728293031 |
- #pragma once
- #include <time.h>
- #include <string>
- #include <system/Thread.h>
- class ntp {
- public:
- ntp();
- virtual ~ntp();
- bool get(struct tm* t);
- static bool get_from(const std::string& ip, struct tm* t);
- };
- class NtpThread : public Thread {
- private:
- //同步时间失败时,重试次数
- int reTry;
- public:
- static NtpThread* getInstance(void);
- bool readyToRun();
- virtual bool threadLoop();
- private:
- NtpThread(){
- reTry = 5;
- }
- ~NtpThread(){}
- };
- #define NTPTHREAD NtpThread::getInstance()
|