protected void processUnit ( Object unit ) { long start = System . nanoTime ( ) ; // keep track of the largest queue size we've seen int queueSize = _evqueue . size ( ) ; if ( queueSize > _current . maxQueueSize ) { _current . maxQueueSize = queueSize ; } try { if ( unit instanceof Runnable ) { // if this is a runnable, it's just an executable unit that should be invoked ( ( Runnable ) unit ) . run ( ) ; } else { DEvent event = ( DEvent ) unit ; // if this event is on a proxied object, forward it to the owning manager ProxyReference proxy = _proxies . get ( event . getTargetOid ( ) ) ; if ( proxy != null ) { // rewrite the oid into the originating manager's id space event . setTargetOid ( proxy . origObjectId ) ; // then pass it on to the originating manager to handle proxy . origManager . postEvent ( event ) ; } else if ( event instanceof CompoundEvent ) { processCompoundEvent ( ( CompoundEvent ) event ) ; } else { processEvent ( event ) ; } } } catch ( VirtualMachineError e ) { handleFatalError ( unit , e ) ; } catch ( Throwable t ) { log . warning ( "Execution unit failed" , "unit" , unit , t ) ; } // compute the elapsed time in microseconds long elapsed = ( System . nanoTime ( ) - start ) / 1000 ; // report excessively long units if ( elapsed > 500000 && ! ( unit instanceof LongRunnable ) ) { log . warning ( "Long dobj unit " + StringUtil . shortClassName ( unit ) , "unit" , unit , "time" , ( elapsed / 1000 ) + "ms" ) ; } // periodically sample and record the time spent processing a unit if ( UNIT_PROF_ENABLED && _eventCount % _unitProfInterval == 0 ) { String cname ; // do some jiggery pokery to get more fine grained profiling details on certain // "popular" unit types if ( unit instanceof Interval . RunBuddy ) { cname = StringUtil . shortClassName ( ( ( Interval . RunBuddy ) unit ) . getIntervalClassName ( ) ) ; } else if ( unit instanceof InvocationRequestEvent ) { InvocationRequestEvent ire = ( InvocationRequestEvent ) unit ; Class < ? > c = _invmgr . getDispatcherClass ( ire . getInvCode ( ) ) ; cname = ( c == null ) ? "dobj.InvocationRequestEvent:(no longer registered)" : StringUtil . shortClassName ( c ) + ":" + ire . getMethodId ( ) ; } else { cname = StringUtil . shortClassName ( unit ) ; } UnitProfile uprof = _profiles . get ( cname ) ; if ( uprof == null ) { _profiles . put ( cname , uprof = new UnitProfile ( ) ) ; } uprof . record ( elapsed ) ; } }
Processes a single unit from the queue .