![]() Writing an agent using the Agents Library is trivial-you need to derive a class from agent, accept the required processing buffers via a constructor or setter method, and override the run method of agent to implement the agent-specific processing logic. Agents and Buffers: The figure shows the various agents and buffers for the sample Agent-based solution. Figure 1 illustrates this solution.įigure 1. It is also possible to identify two memory buffers that will be required-one to hold the collected data, and one to hold the processed data. Three agents can easily be identified-data collection, data processing, and data collation for final display. The data needs to have a computationally expensive transform applied, and finally, the transformed data needs to be processed into a state ready for final display to the end user. Imagine a problem domain where data needs to be collected from some input device such as an open port or file from disk. The first step in developing an Agent-based solution is identifying the discrete agents. By using this well-defined communication mechanism, which guarantees that only one agent is operating on a particular buffer, the Agent Library runtime is free from the need to synchronize access to memory blocks, and can schedule the execution of tasks across any free operating system thread. Once an agent has finished processing a piece of incoming data, it can then pass the result to an outgoing memory buffer where it may be processed in a different way by a different agent.Īgents communicate with each other entirely through the memory buffers that they are operating on, and use Agent Library-provided functions for dealing with these buffers. In contrast, the Asynchronous Agents Library (also referred to by the shorthand name of the “Agents Library”) adopts a more formal approach to achieving parallelism by dividing processing tasks into discrete “agents” that each have a single, well-defined task and operate on a dedicated memory buffer. The PPL supports parallel task execution by automatically moving discrete processing tasks out onto separate threads based on the processing resources that are available at runtime, and achieves synchronization by traditional methods like data locks and events. Previous articles in this series covered the parallel programming library (PPL) and the state management functionality that supports PPL. The Asynchronous Agents Library is the final block of parallel-programming functionality that will ship in Visual C++ 2010. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |