public synchronized Object co_resume ( Object arg_object , int thisCoroutine , int toCoroutine ) throws java . lang . NoSuchMethodException { if ( ! m_activeIDs . get ( toCoroutine ) ) throw new java . lang . NoSuchMethodException ( XMLMessages . createXMLMessage ( XMLErrorResources . ER_COROUTINE_NOT_AVAIL , new Object [ ] { Integer . toString ( toCoroutine ) } ) ) ; //"Coroutine not available, id="+toCoroutine); // We expect these values to be overwritten during the notify()/wait() // periods, as other coroutines in this set get their opportunity to run. m_yield = arg_object ; m_nextCoroutine = toCoroutine ; notify ( ) ; while ( m_nextCoroutine != thisCoroutine || m_nextCoroutine == ANYBODY || m_nextCoroutine == NOBODY ) { try { // System.out.println("waiting..."); wait ( ) ; } catch ( java . lang . InterruptedException e ) { // %TBD% -- Declare? Encapsulate? Ignore? Or // dance deasil about the program counter? } } if ( m_nextCoroutine == NOBODY ) { // Pass it along co_exit ( thisCoroutine ) ; // And inform this coroutine that its partners are Going Away // %REVIEW% Should this throw/return something more useful? throw new java . lang . NoSuchMethodException ( XMLMessages . createXMLMessage ( XMLErrorResources . ER_COROUTINE_CO_EXIT , null ) ) ; //"CoroutineManager recieved co_exit() request"); } return m_yield ; }
Transfer control to another coroutine which has already been started and is waiting on this CoroutineManager . We won t return from this call until that routine has relinquished control .