Tpl Dataflow – Part 1

2011/08/02

Tpl Dataflow – Part 1

this post is the first of post series which will focus

on the new Tpl Dataflow library (TDF).

Tpl, Tpl dataflow, Task, ActionBlock, high-throughput , low-latency

 

TDF goal is to address high-throughput / low-latency

flow scenario of complex computing / IO intensive / immense traffic.

 

The library is using a few basic buffering and message base pattern in order to

enable basic block which can be compose together into full scale scenario.

each building block construct as agent which have internal buffer and execution management.

 

one of the most simple block is the ActionBlock:

Tpl, Tpl dataflow, Task, ActionBlock 

each time item is send into the ActionBlock it will be buffer in

the internal buffer, than the Block Task will take

one item at a-time and will process it.

 

by default the ActionBlock schedule only single Task at a-time,

but latter on this series  we will see that this default can be change.

actually the Block release Its Task whenever the buffer become empty.

 

Code Snippet
  1. var ab = new ActionBlock<int>(i => Console.Write(i));
  2. Parallel.For(0, 1000, i => ab.Post(i));

 

as we can see the ActionBlock syntax can be very simple.

it define an action (in the above case Console.Write) and it can fed with data, ab.Post(i).

 

Summary

ActionBlock is one of the simplest block.

in the future post we will survey other blocks, TDF interfaces, blocks overloads and concepts,

we will see how to chain blocks in a row, and we will

discuss some of the architecture decisions.

 

Point Of Interest:

My lecture on this topic at Microsoft User group has change to 2011-08-17.

you can register using this link.

 

Shout it kick it on DotNetKicks.com

Digg This
Add comment
facebook linkedin twitter email

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>