Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between TPL and TAP

I want to clarify the difference between two these abbreviations: TPL(a task parallel library) and TAP (task async pattern).

AFAIU, TPL - is a task parallel library and the main part of this library is Task and all related staff. So, it's like a technology which was implemented by Microsoft.

TAP - it's a pattern which underlies to async/await syntax sugar. And which is based on callback function + state machine + SynchronizationContext logic.

Is there something to add or correct?

like image 316
totoshka Avatar asked Mar 03 '23 13:03

totoshka


1 Answers

TPL is a part of the BCL. It includes Task as well as several other parallelism-related higher-level abstractions including Parallel and Parallel LINQ. The focus of TPL was parallel processing, and using tasks as futures - while supported - was a relatively unused feature.

TAP is a pattern. It's called "Task-based" because it reused the Task type from the TPL as a generic Future type. Task (and related types) were enhanced to include more primitives to support TAP and asynchronous programming (e.g., GetAwaiter(), Task.WhenAll, etc). These days, TAP also works with "tasklikes" including ValueTask. TAP is focused on asynchronous programming as opposed to parallel processing.

like image 168
Stephen Cleary Avatar answered Mar 13 '23 03:03

Stephen Cleary