Backflow
-
Freitag, 20. April 2012 19:57
Is it possible to implement backflow using TPL data blocks?
How would you go about throttling a pull type mechanism based on the overall flow (of filling of a buffer)?
Alle Antworten
-
Freitag, 20. April 2012 20:52
Could you be more specific? What exactly do you mean by “backflow”? If you mean connecting the blocks so that they form a cycle, then yeah, you can do that.
And throttling in TPL Dataflow is usually done by setting BoundedCapacity in options of some block.
- Bearbeitet svick Freitag, 20. April 2012 20:55
-
Freitag, 20. April 2012 21:48
So if I set a BufferBlock with a bounded capacity of 10, on the 11th post (assuming they arn't propigated) it would block?
Brad Serbu
- Bearbeitet Brad Serbu Freitag, 20. April 2012 21:55
-
Freitag, 20. April 2012 22:04
TPL Dataflow tries to not block any threads. What exactly happens depends on how are the items getting to the BufferBlock.
- If you're using Post(), it will simply return false for the 11th item.
- If you're using SendAsync(), it will return a Task that won't complete until there is space in the block. (And if you Wait() on that Task, then you will block.)
- If some other block is linked to this BufferBlock, then the items will stay in that block and won't move forward.
- Als Antwort markiert Brad Serbu Freitag, 20. April 2012 22:06

