Compare commits

..

2 Commits

Author SHA1 Message Date
422f5d7448 start to implement timeoutmanager 2023-09-26 14:26:07 +02:00
b7403dc872 fix mutex 2023-09-26 14:25:48 +02:00
3 changed files with 29 additions and 11 deletions

View File

@ -22,8 +22,7 @@ namespace interface {
* - Implements the Singleton pattern
* - Handle timeouts (hold, decrement, re-inject)
*/
class XFTimeoutManager
{
class XFTimeoutManager {
public:
virtual ~XFTimeoutManager() = default;

View File

@ -15,12 +15,35 @@ using Mutex = interface::XFMutex; // Rename XFMutex interface class to Mut
// 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
// returned by the 'interface::XFTimeoutManager' class.
interface::XFTimeoutManager * interface::XFTimeoutManager::getInstance()
{
interface::XFTimeoutManager * interface::XFTimeoutManager::getInstance() {
static ::XFTimeoutManager timeoutManager;
return &timeoutManager;
}
// 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

View File

@ -13,12 +13,6 @@ interface::XFMutex * interface::XFMutex::create()
return new ::XFMutex;
}
// TODO: Implement code for XFMutex class
#endif // USE_XF_IDF_QT_MUTEX_CLASS
void XFMutex::lock() {
mutex_.lock();
}
@ -28,5 +22,7 @@ void XFMutex::unlock() {
}
bool XFMutex::tryLock(int32_t timeout) {
mutex_.tryLock(timeout);
return mutex_.tryLock(timeout);
}
#endif // USE_XF_IDF_QT_MUTEX_CLASS