Variable wait time, take 2.

This commit is contained in:
Keith Winstein
2011-08-10 00:32:20 -04:00
parent e7df295f45
commit 79e2898052
+7 -1
View File
@@ -48,6 +48,7 @@ Transport<MyState, RemoteState>::Transport( MyState &initial_state, RemoteState
/* client */ /* client */
} }
/* Returns the number of ms to wait until next (possible) event */
template <class MyState, class RemoteState> template <class MyState, class RemoteState>
int Transport<MyState, RemoteState>::tick( void ) int Transport<MyState, RemoteState>::tick( void )
{ {
@@ -61,9 +62,14 @@ int Transport<MyState, RemoteState>::tick( void )
/* Send diffs or ack */ /* Send diffs or ack */
send_to_receiver(); send_to_receiver();
return SEND_INTERVAL;
} }
int64_t wait = int64_t( sent_states.back().timestamp + SEND_INTERVAL ) - timestamp(); int64_t wait = sent_states.back().timestamp + SEND_INTERVAL - timestamp();
if ( wait < 0 ) {
wait = 0;
}
return wait; return wait;
} }