algo work on test 1
This commit is contained in:
		
							
								
								
									
										11
									
								
								readme.md
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								readme.md
									
									
									
									
									
								
							| @@ -15,7 +15,8 @@ | |||||||
| start | start | ||||||
| :rTime = 0 | :rTime = 0 | ||||||
| relInterval = 0 | relInterval = 0 | ||||||
| isEnd = it == list.end(); | isEnd = it == list.end() | ||||||
|  | lTime = 0; | ||||||
| if (!isEnd) then (not end) | if (!isEnd) then (not end) | ||||||
|  :relInterval = it.getRelTicks() |  :relInterval = it.getRelTicks() | ||||||
|  rTime += relInterval; |  rTime += relInterval; | ||||||
| @@ -24,12 +25,18 @@ if (!isEnd) then (not end) | |||||||
|     :isEnd = (++it == list.end()); |     :isEnd = (++it == list.end()); | ||||||
|         if (!isEnd) then (not end) |         if (!isEnd) then (not end) | ||||||
|             :relInterval = it.getRelTicks() |             :relInterval = it.getRelTicks() | ||||||
|  |             lTime = rTime | ||||||
|             rTime += relInterval; |             rTime += relInterval; | ||||||
|         endif |         endif | ||||||
|     endwhile |     endwhile | ||||||
|      |      | ||||||
| endif | endif | ||||||
| : insert ; | if (!isEnd) then (not end) | ||||||
|  |     : subRelTicks(dTime- lTime); | ||||||
|  | endif | ||||||
|  | :it.setRelTicks(dTime - rTime); | ||||||
|  | :insert(it, timeout); | ||||||
|  |  | ||||||
|  |  | ||||||
| @enduml | @enduml | ||||||
|  |  | ||||||
|   | |||||||
| @@ -38,20 +38,20 @@ void XFTimeoutManager::addTimeout(XFTimeout *pNewTimeout) { | |||||||
|     int rTime = 0; |     int rTime = 0; | ||||||
|     int relInterval = 0; |     int relInterval = 0; | ||||||
|     bool isEnd = true; |     bool isEnd = true; | ||||||
|     int interval = dTime; |     int lTime = 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){ | ||||||
|         relInterval = (*it)->getInterval(); |         relInterval = (*it)->getRelTicks(); | ||||||
|         rTime += relInterval; |         rTime += relInterval; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     while(!isEnd && ( relInterval <= 0 || (rTime > dTime) )) { |     while(!isEnd && ( false || (rTime <= dTime) )) { | ||||||
|         isEnd = (++it == this->timeouts_.end()); |         isEnd = (++it == this->timeouts_.end()); | ||||||
|         interval = rTime - dTime; |         lTime = rTime; | ||||||
|         if(!isEnd) { |         if(!isEnd) { | ||||||
|             relInterval = (*it)->getRelTicks(); |             relInterval = (*it)->getRelTicks(); | ||||||
|             rTime += relInterval; |             rTime += relInterval; | ||||||
| @@ -59,9 +59,9 @@ void XFTimeoutManager::addTimeout(XFTimeout *pNewTimeout) { | |||||||
|     } |     } | ||||||
|     if(it == this->timeouts_.begin()) |     if(it == this->timeouts_.begin()) | ||||||
|  |  | ||||||
|     if(!isEnd) (*it)->substractFromRelTicks(interval); |     if(!isEnd) (*it)->substractFromRelTicks(dTime-lTime); | ||||||
|     it--; |     //it--; | ||||||
|     pNewTimeout->setRelTicks(interval); |     pNewTimeout->setRelTicks(dTime-lTime); | ||||||
|     this->timeouts_.insert(it, pNewTimeout); |     this->timeouts_.insert(it, pNewTimeout); | ||||||
|     this->pMutex_->unlock(); |     this->pMutex_->unlock(); | ||||||
|     return; |     return; | ||||||
| @@ -112,12 +112,12 @@ void XFTimeoutManager::tick() { | |||||||
|  |  | ||||||
|         while (!isEmpty && (rTime <= 0) ) { |         while (!isEmpty && (rTime <= 0) ) { | ||||||
|  |  | ||||||
|             rTime = timeout->getRelTicks(); |  | ||||||
|  |  | ||||||
|             XFDispatcher::getInstance()->pushEvent(timeout); |             XFDispatcher::getInstance()->pushEvent(timeout); | ||||||
|             this->timeouts_.pop_front(); |             this->timeouts_.pop_front(); | ||||||
|  |  | ||||||
|             timeout = this->timeouts_.front(); |             timeout = this->timeouts_.front(); | ||||||
|             isEmpty = this->timeouts_.empty(); |             isEmpty = this->timeouts_.empty(); | ||||||
|  |             if(!isEmpty) rTime = timeout->getRelTicks(); | ||||||
|  |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user