代码之家  ›  专栏  ›  技术社区  ›  amonroejj

System.Threading.Tasks.Dataflow:为什么用List而不是Queue实现标准块类型?

  •  1
  • amonroejj  · 技术社区  · 7 年前

    enter image description here

    How to: Implement a Producer-Consumer Dataflow Pattern

    BufferBlock<T> O(n) 而不是 O(1)

    1 回复  |  直到 7 年前
        1
  •  4
  •   VMAtm    7 年前

    不要根据调试会话得出任何结论,先检查源代码。

    考虑课程信息 BufferBlock<T>

    public IEnumerable<T> Queue { get { return _sourceDebuggingInformation.OutputQueue; } }
    

    Queue 这里的财产来自 调试信息 现场。

    我们来看看 class

    internal IEnumerable<TOutput> OutputQueue { get { return _source._messages.ToList(); } }
    

    同样,正如你所见,这是 调试 .

    _messages 现场。它是 SingleProducerSingleConsumerQueue<T>