| 775 | } |
| 776 | |
| 777 | bool Step(const float maxSleepTime, float* maxWaitTime, float* stepDeltaTime, const NHPTimer::STime now, TStatAggregator* failureStat) { |
| 778 | const float deltaT = (float)NHPTimer::GetSeconds(now - CurrentTime); |
| 779 | *stepDeltaTime = deltaT; |
| 780 | CurrentTime = now; |
| 781 | |
| 782 | RecvCompleted.Cleanup(GetGuid()); |
| 783 | |
| 784 | if (!IsAlive()) { |
| 785 | Y_ASSERT(!PeerLink.IsSleeping()); |
| 786 | Y_ASSERT(InQueue.Empty() && OutQueue.Empty()); |
| 787 | return false; // kill me plz! |
| 788 | |
| 789 | } else if (InQueue.Empty() && OutQueue.Empty()) { |
| 790 | return PeerLink.Sleep(deltaT, maxSleepTime, maxWaitTime); |
| 791 | } else { |
| 792 | //If we are here - we must be active. It is important to handle unexpected killed senders, or some |
| 793 | //network error |
| 794 | Y_ASSERT(IsInactivated() == false); |
| 795 | // we had to stop sleeping after inserting new element to Udp(In|Out)Queue |
| 796 | if (Y_UNLIKELY(PeerLink.IsSleeping())) { |
| 797 | Y_ASSERT(false); |
| 798 | PeerLink.MakeAlive(); // not necessary, just to be sure |
| 799 | } |
| 800 | failureStat->AddPoint(GetFailRate()); |
| 801 | return PeerLink.Update(deltaT, maxWaitTime); |
| 802 | } |
| 803 | } |
| 804 | |
| 805 | TPeerLink& GetAlivePeerLink() { |
| 806 | PeerLink.MakeAlive(); |