Search code examples
c#task-parallel-librarytpl-dataflow

Is there a Filo implementation of a BufferBlock?


I am shoving messages into a BufferBlock, which I then want to route into one of two BufferBlocks. The primary Block (P) will get all messages until there are a certain number of messages in the Buffer. Once the P buffer is filled I want to shove messages into a FILO BufferBlock(S). I then want to consume from these buffers via an ActionBlock where the priority is on S if it has messages.

I think I can figure out how to rig everything together just fine but I tried looking at the implementation of BufferBlock in corefx and I don't think I have what it takes to make it FILO.

TLDR: Is there already an implementation of BufferBlock that's FILO or is there a simple (relative) way to make the BufferBlock FILO by modifying its source from corefx?


Solution

  • Is there already an implementation of BufferBlock that's FILO or is there a simple(relative) way to make the BufferBlock FILO by modifying its source from corefx?

    Not in standard library. If you want to create a new block, you should implement the base interfaces (e.g. IPropagatorBlock) or use static method DataflowBlock.Encapsulate, not to modify the standard block' code.

    You can find additional information on MSDN or in official Introduction to TPL Dataflow.