private void updateTrafficMask ( ) { int queueSize = trafficControllingSessions . size ( ) ; while ( queueSize > 0 ) { T session = trafficControllingSessions . poll ( ) ; if ( session == null ) { return ; } SessionState state = getState ( session ) ; switch ( state ) { case OPENED : updateTrafficControl ( session ) ; break ; case CLOSING : break ; case OPENING : // Retry later if session is not yet fully initialized. // (In case that Session.suspend??() or session.resume??() is // called before addSession() is processed) // We just put back the session at the end of the queue. trafficControllingSessions . add ( session ) ; break ; default : throw new IllegalStateException ( String . valueOf ( state ) ) ; } // As we have handled one session, decrement the number of // remaining sessions. queueSize -- ; } }
Update the trafficControl for all the session which has just been opened .