/// <summary> /// Remove the given Socket from this Poller. /// </summary> /// <param name="handle">the System.Net.Sockets.Socket to remove</param> public void RemoveHandle([NotNull] Socket handle) { PollSet pollSet = m_addList.FirstOrDefault(p => p.Socket == handle); // If the socket was removed before being added there is no reason to mark retired, so just cancelling the socket and removing from add list. // If there is a Pollset with this socket within m_addList, if (pollSet != null) { // Delete that Pollset from m_addList and cancel it. m_addList.Remove(pollSet); pollSet.Cancelled = true; } else // this socket is not within any of the PollSets in m_addList. { // Cancel that PollSet in our list m_handles that has this socket. pollSet = m_handles.First(p => p.Socket == handle); pollSet.Cancelled = true; m_retired = true; } m_checkError.Remove(handle); m_checkRead.Remove(handle); // m_checkWrite.Remove(handle); // Decrease the load metric of the thread. AdjustLoad(-1); }
public void RemoveFD(Socket handle) { PollSet pollset = m_fds.FirstOrDefault(p => p.Socket == handle); if (pollset == null) { pollset = m_tempFDs.First(p => p.Socket == handle); } // Debug.Assert(pollset != null); pollset.Cancelled = true; m_retired = true; FDClear(handle, m_sourceSetIn, ref m_readCount); FDClear(handle, m_sourceSetOut, ref m_writeCount); FDClear(handle, m_sourceSetError, ref m_errorCount); // Decrease the load metric of the thread. AdjustLoad(-1); }