delay 5ms after noticing the user has a queued message before returning it in case other messages arrive immediately thereafter

This commit is contained in:
Andy Janata 2012-01-30 23:54:05 -08:00
parent 7112825580
commit dbb802bb28
1 changed files with 6 additions and 0 deletions

View File

@ -74,6 +74,12 @@ public class LongPollServlet extends CahServlet {
}
}
if (user.hasQueuedMessages()) {
try {
// Delay for a short while in case there will be other messages queued to be delivered.
Thread.sleep(5);
} catch (final InterruptedException ie) {
// pass
}
final Collection<QueuedMessage> msgs = user.getNextQueuedMessages(MAX_MESSAGES_PER_POLL);
// just in case...
if (msgs.size() > 0) {