public void send ( Message msg ) throws Exception { num_senders . incrementAndGet ( ) ; long size = msg . size ( ) ; lock . lock ( ) ; try { if ( count + size >= transport . getMaxBundleSize ( ) ) sendBundledMessages ( ) ; addMessage ( msg , size ) ; // at this point, we haven't sent our message yet ! if ( num_senders . decrementAndGet ( ) == 0 ) // no other sender threads present at this time sendBundledMessages ( ) ; // else there are other sender threads waiting, so our message will be sent by a different thread } finally { lock . unlock ( ) ; } }
current senders adding msgs to the bundler