Пример #1
0
        internal unsafe void FastReadFrom(MessageChunk *first)
        {
            byte *dataPtr = MessageChunk.GetDataPtr(first) + 1; //offset 1 byte type
            long *src     = (long *)(dataPtr);

            TxnPtr  = new IntPtr(*src);
            IsAbort = dataPtr[8] != 0;
        }
Пример #2
0
        internal unsafe void FastReadFrom(MessageChunk *first)
        {
            byte *dataPtr = MessageChunk.GetDataPtr(first);

            ReadCommitted = dataPtr[1] > 0;
            long *src = (long *)(dataPtr + 2);

            WaitHandle = new IntPtr(*src);
        }
Пример #3
0
        internal unsafe void FastReadFrom(MessageChunk *first)
        {
            byte *dataPtr = MessageChunk.GetDataPtr(first);
            long *src     = (long *)(dataPtr + 1);

            TxnPtr     = new IntPtr(*src);
            src        = (long *)(dataPtr + 9);
            WaitHandle = new IntPtr(*src);
        }
Пример #4
0
        public unsafe void Reset(MessageChunk *first)
        {
            //注意:不能加此判断,否则跨进程路由的消息报错
            //if (first->First != first)
            //    throw new ArgumentException(nameof(first));

            _curChunk   = first;
            _curDataPtr = MessageChunk.GetDataPtr(_curChunk);
            _maxDataPtr = _curDataPtr + _curChunk->DataLength;

            //todo:考虑是否实现计算总数据大小
        }
Пример #5
0
        private unsafe bool CheckNeedMove()
        {
            if (_curDataPtr == _maxDataPtr)
            {
                if (_curChunk->Next == null)
                {
                    //_curChunk->DumpAllTcpInfo(true);
                    return(false);
                }

                //移至下一消息段
                _curChunk   = _curChunk->Next;
                _curDataPtr = MessageChunk.GetDataPtr(_curChunk);
                _maxDataPtr = _curDataPtr + _curChunk->DataLength;
            }
            return(true);
        }
Пример #6
0
        private unsafe void CreateChunk()
        {
            var preChunk = _curChunk;

            if (_queue == null)
            {
                _curChunk = (MessageChunk *)ByteBuffer.Pop();
            }
            else
            {
                _curChunk = _queue.GetMessageChunkForWrite();
            }

            //初始化包的消息头
            _curChunk->Type            = (byte)_msgType;
            _curChunk->ID              = _msgID;
            _curChunk->Flag            = (byte)_msgFlag;
            _curChunk->MessageSourceID = _sourceId;
            _curChunk->DataLength      = MessageChunk.PayloadDataSize;
            //需要设置消息链表
            _curChunk->Next = null;
            if (preChunk == null)
            {
                _curChunk->First = _curChunk;
                _curChunk->Flag |= (byte)MessageFlag.FirstChunk;
            }
            else
            {
                preChunk->Next   = _curChunk;
                _curChunk->First = preChunk->First;
            }
            //设置数据部分位置
            _curDataPtr = MessageChunk.GetDataPtr(_curChunk);
            _maxDataPtr = _curDataPtr + MessageChunk.PayloadDataSize;

            //直接发送preChunk
            if (_queue != null && preChunk != null)
            {
                _queue.PostMessageChunk(preChunk);
            }
        }