Esempio n. 1
0
        /// <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);
                    }
                }
            }
        }
Esempio n. 2
0
 /// <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();
 }
Esempio n. 3
0
        /// <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());
        }
Esempio n. 4
0
        /// <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);
        }
Esempio n. 5
0
        /// <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);
                }
            }
        }