//--------------------------------------------------------------------- // ILillTekChannelManager overrides /// <summary> /// Called by LillTek channels accepted by this listener when the /// channel is closed or aborted to terminate any pending operations. /// </summary> /// <param name="channel">The closed or aborted channel.</param> /// <param name="e">The exception to be used to terminate the operation.</param> public override void OnChannelCloseOrAbort(LillTekChannelBase channel, Exception e) { using (TimedLock.Lock(this)) { // Abort any pending operations related to the channel. if (waitQueue != null) { for (int i = waitQueue.Count - 1; i >= 0; i--) { Assertion.Test(waitQueue[i].InternalState != null, "InternalState should have been set to the channel."); if (waitQueue[i].InternalState == channel) { waitQueue[i].Notify(); waitQueue.RemoveAt(i); } } } if (receiveQueue != null) { for (int i = receiveQueue.Count - 1; i >= 0; i--) { Assertion.Test(receiveQueue[i].InternalState != null, "InternalState should have been set to the channel."); if (receiveQueue[i].InternalState == channel) { receiveQueue[i].Notify(); receiveQueue.RemoveAt(i); } } } } base.OnChannelCloseOrAbort(channel, e); }
//--------------------------------------------------------------------- // ILillTekChannelManager implementation /// <summary> /// Called by LillTek channels belonging to this channel manager when the /// channel is closed or aborted to terminate any pending operations. /// </summary> /// <param name="channel">The closed or aborted channel.</param> /// <param name="e">The exception to be used to terminate the operation.</param> public virtual void OnChannelCloseOrAbort(LillTekChannelBase channel, Exception e) { using (TimedLock.Lock(this)) { string channelID = channel.ID; if (channels.ContainsKey(channelID)) { channels.Remove(channelID); } } }
/// <summary> /// Called by derived classes when a new channel is created. /// </summary> /// <param name="channel">The new channel.</param> public virtual void AddChannel(LillTekChannelBase channel) { using (TimedLock.Lock(this)) { if (channels == null) { throw ServiceModelHelper.CreateObjectDisposedException(this); } channels.Add(channel.ID, (TInternal)channel); } }