Benefits of using BufferBlock in dataflow networks

后端 未结 3 804
隐瞒了意图╮
隐瞒了意图╮ 2021-02-01 21:59

I was wondering if there are benefits associated with using a BufferBlock linked to one or many ActionBlocks, other than throttling (using BoundedCapacity), instead of just post

3条回答
  •  面向向阳花
    2021-02-01 22:18

    If all you want to do is to forward items from one block to several others, you don't need BufferBlock.

    But there are certainly cases where it is useful. For example, if you have a complex dataflow network, you might want to build it from smaller sub-networks, each one created in its own method. And to do this, you need some way to represent a group of blocks. In the case you mentioned, returning that single BufferBlock (probably as ITargetBlock) from the method would be an easy solution.

    Another example where BufferBlock would be useful is if you wanted to send items from several source blocks to several target blocks. If you used BufferBlock as an intermediary, you don't have to connect each source block to each target block.

    I'm sure there are many other examples where you could use BufferBlock. Of course, if you don't see any reason to use it in your case, then don't.

提交回复
热议问题