Exemplo n.º 1
0
        /**
         * Creates a new instance.
         *
         * @param output output for kcp
         */
        public Ukcp(KcpOutput output, KcpListener kcpListener, IMessageExecutor iMessageExecutor,
                    ReedSolomon reedSolomon, ChannelConfig channelConfig)
        {
            this._channelConfig    = channelConfig;
            this.kcp               = new Kcp(channelConfig.Conv, output);
            this.active            = true;
            this._kcpListener      = kcpListener;
            this._iMessageExecutor = iMessageExecutor;
            //默认2<<11   可以修改
            _writeQueue = new MpscArrayQueue <IByteBuffer>(2 << 10);
            _readQueue  = new MpscArrayQueue <IByteBuffer>(2 << 10);
            //recieveList = new SpscLinkedQueue<>();
            int headerSize = 0;

            if (channelConfig.KcpTag)
            {
                headerSize += KCP_TAG;
            }

            //init crc32
            if (channelConfig.Crc32Check)
            {
                var kcpOutput = kcp.Output;
                kcpOutput   = new Crc32OutPut(kcpOutput, headerSize);
                kcp.Output  = kcpOutput;
                headerSize += HEADER_CRC;
            }

            //init fec
            if (reedSolomon != null)
            {
                var kcpOutput = kcp.Output;
                _fecEncode  = new FecEncode(headerSize, reedSolomon, channelConfig.Mtu);
                _fecDecode  = new FecDecode(3 * reedSolomon.getTotalShardCount(), reedSolomon, channelConfig.Mtu);
                kcpOutput   = new FecOutPut(kcpOutput, _fecEncode);
                kcp.Output  = kcpOutput;
                headerSize += Fec.fecHeaderSizePlus2;
            }

            kcp.setReserved(headerSize);
            intKcpConfig(channelConfig);
        }
Exemplo n.º 2
0
 internal WriteTaskQueue()
 {
     this.requestPool = new MpscArrayQueue <WriteTask>(MaximumPoolSize);
 }
Exemplo n.º 3
0
 /**
  * 启动消息处理器
  */
 public override void start()
 {
     _queue = new MpscArrayQueue <ITask>(MAX_QUEUE_SIZE);
     base.start();
 }
Exemplo n.º 4
0
 protected MemoryRegionCache(int size, SizeClass sizeClass)
 {
     this.size      = IntegerExtensions.RoundUpToPowerOfTwo(size);
     this.queue     = new MpscArrayQueue <Entry>(this.size);
     this.sizeClass = sizeClass;
 }