Beispiel #1
0
 protected void setDequeueIdentity(ref OperationParameter.NodeParser parser, File.QueueReader reader)
 {
     if (reader != null && !reader.IsDisposed && parser.ValueData.Type == ValueData.DataType.ULong)
     {
         reader.TrySetIdentity(parser.ValueData.Int64.ULong);
     }
 }
Beispiel #2
0
 /// <summary>
 /// 获取当前读取数据标识
 /// </summary>
 /// <param name="getReadIdentity"></param>
 internal override void GetReadIdentity(QueueTaskThread.GetIdentity getReadIdentity)
 {
     if (Writer != null)
     {
         if (!Writer.IsDisposed)
         {
             int readerIndex = getReadIdentity.ReaderIndex;
             if (readerIndex >= readers.Length)
             {
                 readers = readers.copyNew(Math.Min(Math.Max(readers.Length << 1, readerIndex + 1), (int)Config.QueueReader.MaxReaderCount));
             }
             File.QueueReader reader = readers[readerIndex];
             if (reader == null || reader.IsDisposed)
             {
                 reader = new File.QueueReader(this, getReadIdentity.Config, readerIndex);
                 readerDictionary[readerIndex] = reader;
                 readers[readerIndex]          = reader;
             }
             if (!reader.IsDisposed)
             {
                 getReadIdentity.CallOnReturn(reader.Identity);
             }
         }
         else
         {
             getReadIdentity.CallOnReturn(ReturnType.MessageQueueDisposed);
         }
     }
     else
     {
         getReadIdentity.CallOnReturn(ReturnType.MessageQueueNotFoundWriter);
     }
 }
Beispiel #3
0
 /// <summary>
 /// 获取当前读取数据标识
 /// </summary>
 /// <param name="getReadIdentity"></param>
 internal override void GetReadIdentity(QueueTaskThread.GetIdentity getReadIdentity)
 {
     if (Writer != null)
     {
         if (!Writer.IsDisposed)
         {
             if (reader == null || reader.IsDisposed)
             {
                 reader = new File.QueueReader(this, getReadIdentity.Config, 0);
             }
             if (!reader.IsDisposed)
             {
                 getReadIdentity.CallOnReturn(reader.Identity);
             }
         }
         else
         {
             getReadIdentity.CallOnReturn(ReturnType.MessageQueueDisposed);
         }
     }
     else
     {
         getReadIdentity.CallOnReturn(ReturnType.MessageQueueNotFoundWriter);
     }
 }
Beispiel #4
0
        /// <summary>
        /// 查询数据
        /// </summary>
        /// <param name="parser">参数解析</param>
        internal override void QueryEnd(ref OperationParameter.NodeParser parser)
        {
            switch (parser.OperationType)
            {
            case OperationParameter.OperationType.MessageQueueEnqueue: enqueue(ref parser, ValueData.Data <valueType> .DataType); return;

            case OperationParameter.OperationType.MessageQueueGetDequeueIdentity:
                Config.QueueReader config = getReaderConfig(ref parser);
                if (config != null)
                {
                    if (reader == null || reader.IsDisposed)
                    {
                        QueueTaskThread.Thread.Default.Add(new QueueTaskThread.GetIdentity(this, config, ref parser));
                        return;
                    }
                    else
                    {
                        parser.ReturnParameter.Set(reader.Identity);
                    }
                }
                return;

            case OperationParameter.OperationType.MessageQueueDequeue:
                if (parser.ValueData.Type == ValueData.DataType.ULong)
                {
                    File.QueueReader reader = this.reader;
                    if (reader != null && !reader.IsDisposed)
                    {
                        if (parser.OnReturn != null)
                        {
                            QueueTaskThread.Thread.Default.Add(new QueueTaskThread.GetMessage(reader, ref parser));
                        }
                    }
                    else
                    {
                        parser.ReturnParameter.Type = ReturnType.MessageQueueNotFoundReader;
                    }
                }
                else
                {
                    parser.ReturnParameter.Type = ReturnType.ValueDataLoadError;
                }
                return;

            case OperationParameter.OperationType.MessageQueueSetDequeueIdentity: setDequeueIdentity(ref parser, this.reader); return;
            }
            parser.ReturnParameter.Type = ReturnType.OperationTypeError;
        }
Beispiel #5
0
        /// <summary>
        /// 获取下一个节点
        /// </summary>
        /// <param name="parser"></param>
        /// <returns></returns>
        internal override Cache.Node GetQueryNext(ref OperationParameter.NodeParser parser)
        {
            int readerIndex;

            switch (parser.OperationType)
            {
            case OperationParameter.OperationType.MessageQueueGetDequeueIdentity:
                if ((readerIndex = getReaderIndex(ref parser)) >= 0)
                {
                    Config.QueueReader config = getReaderConfig(ref parser);
                    if (config != null)
                    {
                        if (readerIndex < readers.Length)
                        {
                            File.QueueReader reader = readers[readerIndex];
                            if (reader != null && !reader.IsDisposed)
                            {
                                parser.ReturnParameter.Set(reader.Identity);
                                return(null);
                            }
                        }
                        QueueTaskThread.Thread.Default.Add(new QueueTaskThread.GetIdentity(this, config, ref parser, readerIndex));
                    }
                }
                return(null);

            case OperationParameter.OperationType.MessageQueueDequeue:
                if ((readerIndex = getReaderIndex(ref parser)) >= 0)
                {
                    if (parser.ValueData.Type == ValueData.DataType.ULong)
                    {
                        if (readerIndex < readers.Length)
                        {
                            File.QueueReader reader = readers[readerIndex];
                            if (reader != null && !reader.IsDisposed)
                            {
                                if (parser.OnReturn != null)
                                {
                                    QueueTaskThread.Thread.Default.Add(new QueueTaskThread.GetMessage(reader, ref parser));
                                }
                                return(null);
                            }
                        }
                        parser.ReturnParameter.Type = ReturnType.MessageQueueNotFoundReader;
                    }
                    else
                    {
                        parser.ReturnParameter.Type = ReturnType.ValueDataLoadError;
                    }
                }
                return(null);

            case OperationParameter.OperationType.MessageQueueSetDequeueIdentity:
                if ((uint)(readerIndex = getReaderIndex(ref parser)) < readers.Length)
                {
                    setDequeueIdentity(ref parser, readers[readerIndex]);
                }
                return(null);
            }
            parser.ReturnParameter.Type = ReturnType.OperationTypeError;
            return(null);
        }