Dmitri Nesteruk
dmitrinesteruk@gmail.com
A publishes an event
B subscribes to the event
If lifetime of B < lifetime of A
We can get a memory leak

Weak event patte...
Library for composing async/event-based
programs
Event subscription wrapped as IDisposable
Lets you manually unsubscribe
U...
Declarative subscriptions
Pub/sub mechanism

Objects not aware of each other
Typically built on top of a DI container
Each...
Erlang
F# MailboxProcessor
Axum (dead)
Task Parallel Library (TPL) DataFlow
A library approach 
Fine-grained
Data-level (SIMD) – not in .NET
Autoparallelization

Coarse-grained
Using threads
Weird synchronization primi...
A directed graph of data
Message passing
Buffering
Parallel execution
Dependency management
Pipeline
read

process

Network
read

process

write

process
collate

prepare
process

write
Input

Propagate

Calculate
indices

Output
Render to
screen
Save to DB

Read stock
market data
Filter

Save to DB
ISourceBlock<T>
Source of data; read

ITargetBlock<T>
Where you write the data to

IPropagatorBlock<TIn,TOut>
Propagator; ...
TransformBlock
Transforms data
Also: TransformManyBlock

ActionBlock
Processes the data
Post()
Sends a piece of data to the block for processing

LinkTo ()
Links a block with the next block in the graph
Takes a...
Basic block processing
BatchBlock<T>
Combines sets of blocks into an array

JoinBlock<2> and <3>
Collects 2 or 3 inputs into a Tuple<2/3>

BatchJ...
Provides a data storage buffer
Can be used synchronously
block.Post()
block.Receive()

or asynchronously
await block.SendA...
Grouping Blocks
Not a competitor to Rx or TPL itself
Course-grained parallelization/sequencing
mechanism
‘Cheap’ multithreading
Questions?
Конференция по .NET технологиям
4 апреля 2014, ПетроКонгресс
http://dotnext.ru
Предлагайте доклады 
Upcoming SlideShare
Loading in …5
×

Tpl DataFlow

1,034 views

Published on

Slides from my talk on TPL DataFlow given at the 33rd meeting of the Spbalt.net user group.

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,034
On SlideShare
0
From Embeds
0
Number of Embeds
33
Actions
Shares
0
Downloads
16
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Tpl DataFlow

  1. 1. Dmitri Nesteruk dmitrinesteruk@gmail.com
  2. 2. A publishes an event B subscribes to the event If lifetime of B < lifetime of A We can get a memory leak Weak event pattern
  3. 3. Library for composing async/event-based programs Event subscription wrapped as IDisposable Lets you manually unsubscribe Unsubscription automatic when source runs out of data to supply
  4. 4. Declarative subscriptions Pub/sub mechanism Objects not aware of each other Typically built on top of a DI container Each component references the broker
  5. 5. Erlang F# MailboxProcessor Axum (dead) Task Parallel Library (TPL) DataFlow A library approach 
  6. 6. Fine-grained Data-level (SIMD) – not in .NET Autoparallelization Coarse-grained Using threads Weird synchronization primitives (e.g. Pulse&Wait) TPL DataFlow
  7. 7. A directed graph of data Message passing Buffering Parallel execution Dependency management
  8. 8. Pipeline read process Network read process write process collate prepare process write
  9. 9. Input Propagate Calculate indices Output Render to screen Save to DB Read stock market data Filter Save to DB
  10. 10. ISourceBlock<T> Source of data; read ITargetBlock<T> Where you write the data to IPropagatorBlock<TIn,TOut> Propagator; performs data processing/filtering As with Rx, ready-made implementations provided
  11. 11. TransformBlock Transforms data Also: TransformManyBlock ActionBlock Processes the data
  12. 12. Post() Sends a piece of data to the block for processing LinkTo () Links a block with the next block in the graph Takes an optional predicate Returns an Idisposable CancelationTokenSource if you change your mind
  13. 13. Basic block processing
  14. 14. BatchBlock<T> Combines sets of blocks into an array JoinBlock<2> and <3> Collects 2 or 3 inputs into a Tuple<2/3> BatchJoinBlock Merger of the above Collects Tuple<IList<T>,…>
  15. 15. Provides a data storage buffer Can be used synchronously block.Post() block.Receive() or asynchronously await block.SendAsync() Await block.ReceiveAsync()
  16. 16. Grouping Blocks
  17. 17. Not a competitor to Rx or TPL itself Course-grained parallelization/sequencing mechanism ‘Cheap’ multithreading
  18. 18. Questions?
  19. 19. Конференция по .NET технологиям 4 апреля 2014, ПетроКонгресс http://dotnext.ru Предлагайте доклады 

×