/// <summary> /// Poll readers. /// </summary> /// <param name="mux">The current mux.</param> /// <param name="threadIndex">The current thread index.</param> private void PollReadEx(IMultiplexed mux, int threadIndex) { if (null == mux) { return; } if (mux.Suspend) { return; } mux.ReadyRead(); // Only if write polling is enabled. if (_pollWriter) { // If not listener. if (!mux.IsListener) { _pollWriterInt[threadIndex] = true; // If the write job does not exist. if (!_writeQueues[threadIndex].Contains(mux)) { _writeQueues[threadIndex].Add(mux); } } } }
/// <summary> /// Poll errors. /// </summary> /// <param name="mux">The current mux.</param> private void PollErrorEx(IMultiplexed mux) { if (null == mux) { return; } if (mux.Suspend) { return; } mux.ErrorState(); }
/// <summary> /// Get the list of muxes. /// </summary> /// <param name="socketList">The list of sockets to split.</param> /// <returns>The collection of muxes;</returns> private IMultiplexed[] GetMuxes(ArrayList socketList) { List <IMultiplexed> list = new List <IMultiplexed>(); // For each socket that is ready to read. foreach (Socket socket in socketList) { IMultiplexed mux = GetMux(socket); list.Add(mux); } // Return the mux return(list.ToArray()); }
/// <summary> /// Register a <see cref="Socket"/> for issuing notifications. /// </summary> /// <param name="socket">The socket to register.</param> /// <param name="multiplexed"> /// An object that implements the <see cref="IMultiplexed"/> inteface. /// </param> public void AddSocket(Socket socket, IMultiplexed multiplexed) { if (socket == null) { throw new ArgumentNullException("socket"); } if (multiplexed == null) { throw new ArgumentNullException("multiplexed"); } lock (_lockSocketsObject) _multiplexers.Add(socket, multiplexed); }
/// <summary> /// Poll writers. /// </summary> /// <param name="index">The current write queue index.</param> /// <param name="threadIndex">The current thread index.</param> private void PollWriteEx(int index, int threadIndex) { // Get the current write operation. IMultiplexed mux = _writeQueues[threadIndex][index];; // If not listener. if (!mux.IsListener) { // Write operation. bool allSent = mux.ReadyWrite(); if (!allSent) { // Remove the mux from the queue // If all data has been writen. _writeQueueToRemoves[threadIndex].Add(mux); } } }