clean algo (work for all tests)
This commit is contained in:
parent
20fd0631c6
commit
05f186188f
32
readme.md
32
readme.md
@ -13,30 +13,28 @@
|
|||||||
@startuml
|
@startuml
|
||||||
|
|
||||||
start
|
start
|
||||||
:rTime = 0
|
:newTime = 0
|
||||||
relInterval = 0
|
totalTime = 0
|
||||||
isEnd = it == list.end()
|
isEnd = it == list.end()
|
||||||
lTime = 0;
|
lastTime = 0;
|
||||||
if (!isEnd) then (not end)
|
|
||||||
:relInterval = it.getRelTicks()
|
|
||||||
rTime += relInterval;
|
|
||||||
|
|
||||||
while ( !isEnd && ( relInterval <= 0 || (rTime < dTime) ) is (goForward)
|
#tomato:if (!isEnd) then (not end)
|
||||||
|
#tomato:totalTime += it.getRelTicks();
|
||||||
|
endif
|
||||||
|
|
||||||
|
while ( !isEnd && (totalTime <= newTime) ) is (goForward)
|
||||||
:isEnd = (++it == list.end());
|
:isEnd = (++it == list.end());
|
||||||
if (!isEnd) then (not end)
|
:lastTime = totalTime;
|
||||||
:relInterval = it.getRelTicks()
|
#tomato:if (!isEnd) then (not end)
|
||||||
lTime = rTime
|
#tomato:totalTime += it.getRelTicks();
|
||||||
rTime += relInterval;
|
|
||||||
endif
|
endif
|
||||||
endwhile
|
endwhile
|
||||||
|
|
||||||
|
#tomato:if (!isEnd) then (not end)
|
||||||
|
#tomato:subRelTicks(newTime- lastTime);
|
||||||
endif
|
endif
|
||||||
if (!isEnd) then (not end)
|
:it.setRelTicks(newTime - lastTime);
|
||||||
: subRelTicks(dTime- lTime);
|
:insert(it, newTimeout);
|
||||||
endif
|
|
||||||
:it.setRelTicks(dTime - rTime);
|
|
||||||
:insert(it, timeout);
|
|
||||||
|
|
||||||
|
|
||||||
@enduml
|
@enduml
|
||||||
|
|
||||||
|
@ -34,37 +34,29 @@ XFTimeoutManager::~XFTimeoutManager() {
|
|||||||
|
|
||||||
void XFTimeoutManager::addTimeout(XFTimeout *pNewTimeout) {
|
void XFTimeoutManager::addTimeout(XFTimeout *pNewTimeout) {
|
||||||
|
|
||||||
const int dTime = pNewTimeout->getInterval();
|
const int newTime = pNewTimeout->getInterval();
|
||||||
int rTime = 0;
|
int totalTime = 0;
|
||||||
int relInterval = 0;
|
|
||||||
bool isEnd = true;
|
bool isEnd = true;
|
||||||
int lTime = 0;
|
int lastTime = 0;
|
||||||
|
|
||||||
this->pMutex_->lock();
|
this->pMutex_->lock();
|
||||||
TimeoutList::iterator it = this->timeouts_.begin();
|
TimeoutList::iterator it = this->timeouts_.begin();
|
||||||
isEnd = (it == this->timeouts_.end());
|
isEnd = (it == this->timeouts_.end());
|
||||||
|
|
||||||
if(!isEnd){
|
if(!isEnd) totalTime += (*it)->getRelTicks();
|
||||||
relInterval = (*it)->getRelTicks();
|
|
||||||
rTime += relInterval;
|
|
||||||
}
|
|
||||||
|
|
||||||
while(!isEnd && ( false || (rTime <= dTime) )) {
|
while(!isEnd && (totalTime <= newTime)) {
|
||||||
isEnd = (++it == this->timeouts_.end());
|
isEnd = (++it == this->timeouts_.end());
|
||||||
lTime = rTime;
|
lastTime = totalTime;
|
||||||
if(!isEnd) {
|
if(!isEnd) totalTime += (*it)->getRelTicks();
|
||||||
relInterval = (*it)->getRelTicks();
|
|
||||||
rTime += relInterval;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(it == this->timeouts_.begin())
|
|
||||||
|
|
||||||
if(!isEnd) (*it)->substractFromRelTicks(dTime-lTime);
|
if(!isEnd) (*it)->substractFromRelTicks(newTime-lastTime);
|
||||||
//it--;
|
|
||||||
pNewTimeout->setRelTicks(dTime-lTime);
|
pNewTimeout->setRelTicks(newTime-lastTime);
|
||||||
this->timeouts_.insert(it, pNewTimeout);
|
this->timeouts_.insert(it, pNewTimeout);
|
||||||
|
|
||||||
this->pMutex_->unlock();
|
this->pMutex_->unlock();
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user