/// <summary> /// Marks the beginning of an I/O operation that might block indefinitely. /// /// <para> This method should be invoked in tandem with the <seealso cref="#end end"/> /// method, using a <tt>try</tt> ... <tt>finally</tt> block as /// shown <a href="#be">above</a>, in order to implement interruption for /// this selector. /// /// </para> /// <para> Invoking this method arranges for the selector's {@link /// Selector#wakeup wakeup} method to be invoked if a thread's {@link /// Thread#interrupt interrupt} method is invoked while the thread is /// blocked in an I/O operation upon the selector. </para> /// </summary> protected internal void Begin() { if (Interruptor == null) { Interruptor = new InterruptibleAnonymousInnerClassHelper(this); } AbstractInterruptibleChannel.BlockedOn(Interruptor); Thread me = Thread.CurrentThread; if (me.Interrupted) { Interruptor.interrupt(me); } }
/// <summary> /// Marks the end of an I/O operation that might block indefinitely. /// /// <para> This method should be invoked in tandem with the <seealso cref="#begin begin"/> /// method, using a <tt>try</tt> ... <tt>finally</tt> block as /// shown <a href="#be">above</a>, in order to implement interruption for /// this selector. </para> /// </summary> protected internal void End() { AbstractInterruptibleChannel.BlockedOn(null); }
public InterruptibleAnonymousInnerClassHelper(AbstractInterruptibleChannel outerInstance) { this.OuterInstance = outerInstance; }