FastFlow  SVN-r182-Aug-14-2014
A high-level, lock-less, parallel programming (shared-memory) and distributed programming (distributed-memory) framework for multi-cores and many-cores systems
 All Classes Namespaces Files Functions Variables Typedefs Groups Pages
Classes | Namespaces

Farm pattern. More...

#include <iostream>
#include <vector>
#include <algorithm>
#include <ff/platforms/platform.h>
#include <ff/lb.hpp>
#include <ff/gt.hpp>
#include <ff/node.hpp>
#include <functional>
+ Include dependency graph for farm.hpp:
+ This graph shows which files directly or indirectly include this file:

Classes

class  ff::ff_farm< lb_t, gt_t >
 The Farm skeleton, with Emitter (lb_t) and Collector (gt_t). More...
 
class  ff::ofarm_lb
 Ordered farm emitter. More...
 
class  ff::ofarm_gt
 Ordered farm Collector. More...
 
class  ff::ff_ofarm
 The ordered Farm skeleton. More...
 
class  ff::ff_minode
 Multiple input ff_node (the MPSC mediator) More...
 
class  ff::ff_monode
 Multiple output ff_node (the SPMC mediator) More...
 

Namespaces

 ff
 The principal namespace for the FastFlow library.
 

Detailed Description

Farm pattern.

It works on a stream of tasks. Workers are non-blocking threads not tasks. It is composed by: Emitter (E), Workers (W), Collector (C). They all are C++ objects. Overall, it has one (optional) input stream and one (optional) output stream. Emitter gets stream items (tasks, i.e. C++ objects) and disptach them to Workers (activating svc method). On svn return (or ff_send_out call), tasks are sent to Collector that gather them and output them in the output stream.

Dispatching policy can be configured in the Emitter. Gathering policy in the Collector.

In case of no output stream the Collector is usually not needed. Emitter should always exist, even with no input stream.

There exists several variants of the farm pattern, including

Todo:
Includes classes at different levels. To be split sooner or later. High level farm function to be wrapped in a separate class.