Variable wait time

This commit is contained in:
Keith Winstein
2011-08-10 00:13:22 -04:00
parent 4a90f6a0ef
commit e7df295f45
3 changed files with 13 additions and 14 deletions
+10 -7
View File
@@ -49,19 +49,22 @@ Transport<MyState, RemoteState>::Transport( MyState &initial_state, RemoteState
}
template <class MyState, class RemoteState>
void Transport<MyState, RemoteState>::tick( void )
int Transport<MyState, RemoteState>::tick( void )
{
/* Update assumed receiver state */
update_assumed_receiver_state();
/* Cut out common prefix of all states */
rationalize_states();
/* Determine if a new diff or empty ack needs to be sent */
if ( timestamp() - sent_states.back().timestamp >= int64_t( SEND_INTERVAL ) ) {
/* Update assumed receiver state */
update_assumed_receiver_state();
/* Cut out common prefix of all states */
rationalize_states();
/* Send diffs or ack */
send_to_receiver();
}
int64_t wait = int64_t( sent_states.back().timestamp + SEND_INTERVAL ) - timestamp();
return wait;
}
template <class MyState, class RemoteState>