Use mono time for event arrival time
This commit is contained in:
parent
d7bffa4ade
commit
b0695b08a5
@ -41,7 +41,7 @@ constexpr bool isConnectionRequestPacket(unsigned char* data, size_t length)
|
|||||||
// ============================================================================
|
// ============================================================================
|
||||||
Event::Event(ENetEvent* event, std::shared_ptr<STKPeer> peer)
|
Event::Event(ENetEvent* event, std::shared_ptr<STKPeer> peer)
|
||||||
{
|
{
|
||||||
m_arrival_time = (double)StkTime::getTimeSinceEpoch();
|
m_arrival_time = StkTime::getMonoTimeMs();
|
||||||
m_pdi = PDI_TIMEOUT;
|
m_pdi = PDI_TIMEOUT;
|
||||||
m_peer = peer;
|
m_peer = peer;
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ private:
|
|||||||
std::shared_ptr<STKPeer> m_peer;
|
std::shared_ptr<STKPeer> m_peer;
|
||||||
|
|
||||||
/** Arrivial time of the event, for timeouts. */
|
/** Arrivial time of the event, for timeouts. */
|
||||||
double m_arrival_time;
|
uint64_t m_arrival_time;
|
||||||
|
|
||||||
/** For disconnection event, a bit more info is provided. */
|
/** For disconnection event, a bit more info is provided. */
|
||||||
PeerDisconnectInfo m_pdi;
|
PeerDisconnectInfo m_pdi;
|
||||||
@ -119,7 +119,7 @@ public:
|
|||||||
m_data->isSynchronous(); }
|
m_data->isSynchronous(); }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Returns the arrival time of this event. */
|
/** Returns the arrival time of this event. */
|
||||||
double getArrivalTime() const { return m_arrival_time; }
|
uint64_t getArrivalTime() const { return m_arrival_time; }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
PeerDisconnectInfo getPeerDisconnectInfo() const { return m_pdi; }
|
PeerDisconnectInfo getPeerDisconnectInfo() const { return m_pdi; }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
@ -449,7 +449,8 @@ bool ProtocolManager::sendEvent(Event* event)
|
|||||||
can_be_deleted |= m_all_protocols.at(i).notifyEvent(event);
|
can_be_deleted |= m_all_protocols.at(i).notifyEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return can_be_deleted || StkTime::getTimeSinceEpoch() - event->getArrivalTime()
|
const uint64_t TIME_TO_KEEP_EVENTS = 1000;
|
||||||
|
return can_be_deleted || StkTime::getMonoTimeMs() - event->getArrivalTime()
|
||||||
>= TIME_TO_KEEP_EVENTS;
|
>= TIME_TO_KEEP_EVENTS;
|
||||||
} // sendEvent
|
} // sendEvent
|
||||||
|
|
||||||
|
@ -41,8 +41,6 @@
|
|||||||
class Event;
|
class Event;
|
||||||
class STKPeer;
|
class STKPeer;
|
||||||
|
|
||||||
#define TIME_TO_KEEP_EVENTS 1.0
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
/** \enum ProtocolRequestType
|
/** \enum ProtocolRequestType
|
||||||
* \brief Defines actions that can be done about protocols.
|
* \brief Defines actions that can be done about protocols.
|
||||||
|
Loading…
Reference in New Issue
Block a user