forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[syncd] Move syncd classes to syncd namespace (sonic-net#742)
Code clean refactor
- Loading branch information
Showing
6 changed files
with
76 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,55 @@ | ||
#pragma once | ||
|
||
#include "swss/sal.h" | ||
|
||
#include <thread> | ||
#include <atomic> | ||
#include <functional> | ||
|
||
#ifndef _In_ | ||
#define _In_ | ||
#endif | ||
|
||
class TimerWatchdog | ||
namespace syncd | ||
{ | ||
typedef void (*Callback)( | ||
_In_ int64_t span); | ||
|
||
public: | ||
|
||
TimerWatchdog( | ||
_In_ int64_t warnTimespan); | ||
class TimerWatchdog | ||
{ | ||
public: | ||
|
||
virtual ~TimerWatchdog(); | ||
TimerWatchdog( | ||
_In_ int64_t warnTimespan); | ||
|
||
public: | ||
virtual ~TimerWatchdog(); | ||
|
||
void setStartTime(); | ||
public: | ||
|
||
void setEndTime(); | ||
void setStartTime(); | ||
|
||
void setCallback( | ||
_In_ Callback callback); | ||
void setEndTime(); | ||
|
||
/** | ||
* @brief Gets timestamp since epoch. | ||
* | ||
* @return Time since epoch in microseconds. | ||
*/ | ||
static int64_t getTimeSinceEpoch(); | ||
void setCallback( | ||
_In_ std::function<void(uint64_t)> callback); | ||
|
||
private: | ||
/** | ||
* @brief Gets timestamp since epoch. | ||
* | ||
* @return Time since epoch in microseconds. | ||
*/ | ||
static int64_t getTimeSinceEpoch(); | ||
|
||
void threadFunction(); | ||
private: | ||
|
||
private: | ||
void threadFunction(); | ||
|
||
volatile bool m_run; | ||
private: | ||
|
||
// all values are in microseconds | ||
volatile bool m_run; | ||
|
||
std::atomic_int_fast64_t m_warnTimespan; | ||
std::atomic_int_fast64_t m_startTimestamp; | ||
std::atomic_int_fast64_t m_endTimestamp; | ||
std::atomic_int_fast64_t m_lastCheckTimestamp; | ||
// all values are in microseconds | ||
|
||
std::shared_ptr<std::thread> m_thread; | ||
std::atomic_int_fast64_t m_warnTimespan; | ||
std::atomic_int_fast64_t m_startTimestamp; | ||
std::atomic_int_fast64_t m_endTimestamp; | ||
std::atomic_int_fast64_t m_lastCheckTimestamp; | ||
|
||
Callback m_callback; | ||
std::shared_ptr<std::thread> m_thread; | ||
|
||
}; | ||
std::function<void(uint64_t)> m_callback; | ||
}; | ||
} |