/** * Reads an <TT>Object</TT> from the channel. * * @return the object read from the channel. */ public Object read() { /*synchronized*/ lock (rwMonitor) { if (data.getState() == ChannelDataStoreState.EMPTY) { try { Monitor.Wait(rwMonitor); while (data.getState() == ChannelDataStoreState.EMPTY) { if (Spurious.logging) { SpuriousLog.record(SpuriousLog.One2OneChannelXRead); } Monitor.Wait(rwMonitor); } } catch (ThreadInterruptedException e) { throw new ProcessInterruptedException( "*** Thrown from One2OneChannel.read (int)\n" + e.ToString() ); } } Monitor.Pulse(rwMonitor); return(data.get()); } }
/** * Reads an <TT>Object</TT> from the channel. * * @return the object read from the channel. */ public Object read() { lock (rwMonitor) { if (data.getState() == ChannelDataStoreState.EMPTY) { //Reader only sees poison if buffer is empty: if (isPoisoned()) { throw new PoisonException(poisonStrength); } try { Monitor.Wait(rwMonitor); while (data.getState() == ChannelDataStoreState.EMPTY && !isPoisoned()) { if (Spurious.logging) { SpuriousLog.record(SpuriousLog.One2OneChannelXRead); } Monitor.Wait(rwMonitor); } } catch (ThreadInterruptedException e) { throw new ProcessInterruptedException( "*** Thrown from One2OneChannel.read (int)\n" + e.ToString() ); } if (isPoisoned()) { throw new PoisonException(poisonStrength); } } Monitor.Pulse(rwMonitor); return(data.get()); } }