/** * Reads an <TT>int</TT> from the channel. * * @return the integer read from the channel. */ public int read() { lock (rwMonitor) { if (data.getState() == ChannelDataStoreState.EMPTY) { try { Monitor.Wait(rwMonitor); while (data.getState() == ChannelDataStoreState.EMPTY) { if (Spurious.logging) { SpuriousLog.record(SpuriousLog.One2OneChannelIntXRead); } Monitor.Wait(rwMonitor); } } catch (ThreadInterruptedException�e) { throw new ProcessInterruptedException( "*** Thrown from One2OneChannelInt.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 int 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()); } }