Compare commits
No commits in common. "422f5d744884e851e1ccbb698dfd75c397bb0dcf" and "56516fa7c85dec0dfb468b009244da00f377a3ce" have entirely different histories.
422f5d7448
...
56516fa7c8
@ -22,7 +22,8 @@ namespace interface {
|
|||||||
* - Implements the Singleton pattern
|
* - Implements the Singleton pattern
|
||||||
* - Handle timeouts (hold, decrement, re-inject)
|
* - Handle timeouts (hold, decrement, re-inject)
|
||||||
*/
|
*/
|
||||||
class XFTimeoutManager {
|
class XFTimeoutManager
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~XFTimeoutManager() = default;
|
virtual ~XFTimeoutManager() = default;
|
||||||
|
|
||||||
|
@ -15,35 +15,12 @@ using Mutex = interface::XFMutex; // Rename XFMutex interface class to Mut
|
|||||||
// Note: The implementation is done here because only in this file the real XFTimeoutManager
|
// Note: The implementation is done here because only in this file the real XFTimeoutManager
|
||||||
// class is known (port specific class). An instance of the XFTimeoutManager class is
|
// class is known (port specific class). An instance of the XFTimeoutManager class is
|
||||||
// returned by the 'interface::XFTimeoutManager' class.
|
// returned by the 'interface::XFTimeoutManager' class.
|
||||||
interface::XFTimeoutManager * interface::XFTimeoutManager::getInstance() {
|
interface::XFTimeoutManager * interface::XFTimeoutManager::getInstance()
|
||||||
|
{
|
||||||
static ::XFTimeoutManager timeoutManager;
|
static ::XFTimeoutManager timeoutManager;
|
||||||
return &timeoutManager;
|
return &timeoutManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Implement code for XFTimeoutManager class
|
// TODO: Implement code for XFTimeoutManager class
|
||||||
|
|
||||||
XFTimeoutManager::XFTimeoutManager() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
XFTimeoutManager::~XFTimeoutManager() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void XFTimeoutManager::start(std::function<void (uint32_t)> startTimeoutManagerTimer) {
|
|
||||||
startTimeoutManagerTimer(tickInterval_);
|
|
||||||
}
|
|
||||||
|
|
||||||
void XFTimeoutManager::scheduleTimeout(int32_t timeoutId, int32_t interval, interface::XFBehavior *pBehavior) {
|
|
||||||
::XFTimeout* timeout = new XFTimeout(timeoutId, interval, pBehavior);
|
|
||||||
timeouts_.push_front(timeout);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t timeoutIdComparison;
|
|
||||||
bool myPredicate(XFTimeout* timeout) {return (timeout->getId()==timeoutIdComparison);}
|
|
||||||
void XFTimeoutManager::unscheduleTimeout(int32_t timeoutId, interface::XFBehavior *pBehavior) {
|
|
||||||
timeoutIdComparison = timeoutId;
|
|
||||||
timeouts_.remove_if(myPredicate);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // USE_XF_COMMON_TIMEOUTMANAGER_CLASS
|
#endif // USE_XF_COMMON_TIMEOUTMANAGER_CLASS
|
||||||
|
@ -13,6 +13,12 @@ interface::XFMutex * interface::XFMutex::create()
|
|||||||
return new ::XFMutex;
|
return new ::XFMutex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Implement code for XFMutex class
|
||||||
|
|
||||||
|
#endif // USE_XF_IDF_QT_MUTEX_CLASS
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void XFMutex::lock() {
|
void XFMutex::lock() {
|
||||||
mutex_.lock();
|
mutex_.lock();
|
||||||
}
|
}
|
||||||
@ -22,7 +28,5 @@ void XFMutex::unlock() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool XFMutex::tryLock(int32_t timeout) {
|
bool XFMutex::tryLock(int32_t timeout) {
|
||||||
return mutex_.tryLock(timeout);
|
mutex_.tryLock(timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // USE_XF_IDF_QT_MUTEX_CLASS
|
|
||||||
|
Reference in New Issue
Block a user