![]() ![]() The next step may be responsible for parsing the HTML from the downloaded file and the final step may be responsible for searching the text content for a keyword. The next step may be responsible for saving the downloaded content to file. The next step may be responsible for downloading the URL into memory. The first step may read a list of URLs from a file and produce each URL as a task. ![]() Run your loops using all CPUs, download my FREE book to learn how.Ī pipeline of tasks executed by threads can be a useful pattern in concurrent programming.įor example, we might imagine a series of steps to search a series of webpages for a keyword. Now that we are familiar with a thread pipeline, let’s consider why we might to use a thread pipeline. This allows the steps of the pipeline to be scaled independently, perhaps based on the speed of processing of each step. Like the producer-consumer pattern, each step in the pipeline may be executed by one or more threads concurrently. Similarly the last step of the pipeline may consume and process work items without producing anything. The first step of the pipeline may only produce work items without consuming anything. The exception to this is the first and last step in the pipeline. Pipeline Task: Consume items from the previous step and produce an item for the next step.That is, each step in the pipeline may consume an item from the previous step in the pipeline, perform some processing, then produce an item for the next step in the pipeline. In a pipeline, each task may be a producer and consumer. It involves producer tasks, consumer tasks and a shared buffer or queue that connects these two types of tasks. Recall that the Producer-Consumer pattern is a common concurrency programming design pattern. ![]() We might consider a series of producer-consumer tasks, each executed by one or more threads and connected by queues. A pipeline is a linear series of tasks that build on each other.Įach task or step in the pipeline executes concurrently, reading and processing units of work from the previous step and writing the result to the next step. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |