// and that is available also as a fall-back whenever via boost or similar
/**
- * A class that creates a sequence of
- * items from a range of iterators.
+ * A class that creates a sequence of items from a range of iterators.
*/
template <typename Iterator,
typename ScratchData,
{
public:
/**
- * A data type that we use to identify
- * items to be worked on. This is the structure
- * that is passed around between the different parts of
- * the WorkStream implementation to identify what needs
- * to be done by the various stages of the pipeline.
+ * A data type that we use to identify items to be worked on. This is
+ * the structure that is passed around between the different parts of
+ * the WorkStream implementation to identify what needs to be done by
+ * the various stages of the pipeline.
*/
struct ItemType
{
/**
* Default constructor.
- * Initialize everything that doesn't
- * have a default constructor itself.
+ * Initialize everything that doesn't have a default constructor
+ * itself.
*/
ItemType ()
:
/**
- * Constructor. Take an iterator
- * range, the size of a buffer that
- * can hold items, and the sample
- * additional data object that will
- * be passed to each worker and
- * copier function invokation.
+ * Constructor. Take an iterator range, the size of a buffer that can
+ * hold items, and the sample additional data object that will be passed
+ * to each worker and copier function invokation.
*/
IteratorRangeToItemStream (const Iterator &begin,
const Iterator &end,
}
- // return an invalid
- // item since we are at
- // the end of the
+ // return an invalid item since we are at the end of the
// pipeline
return 0;
}
private:
/**
- * Pointer to the function
- * that does the copying of
- * data.
+ * Pointer to the function that does the copying of data.
*/
const std_cxx1x::function<void (const CopyData &)> copier;
};
/**
- * This is the main function of the
- * WorkStream concept, doing work as
- * described in the introduction to this
- * namespace.
+ * This is the main function of the WorkStream concept, doing work as
+ * described in the introduction to this namespace.
*
- * This is the function that can be used
- * for worker and copier objects that are
- * either pointers to non-member
- * functions or objects that allow to be
- * called with an operator(), for example
- * objects created by std::bind.
+ * This is the function that can be used for worker and copier objects that
+ * are either pointers to non-member functions or objects that allow to be
+ * called with an operator(), for example objects created by std::bind.
*
- * The argument passed as @p end must be
- * convertible to the same type as
- * @p begin, but doesn't have to be of the
- * same type itself. This allows to write
- * code like
- * <code>WorkStream().run(dof_handler.begin_active(),
- * dof_handler.end(), ...</code> where
- * the first is of type
- * DoFHandler::active_cell_iterator
- * whereas the second is of type
+ * The argument passed as @p end must be convertible to the same type as @p
+ * begin, but doesn't have to be of the same type itself. This allows to
+ * write code like <code>WorkStream().run(dof_handler.begin_active(),
+ * dof_handler.end(), ...</code> where the first is of type
+ * DoFHandler::active_cell_iterator whereas the second is of type
* DoFHandler::raw_cell_iterator.
*
- * The two data types
- * <tt>ScratchData</tt> and
- * <tt>CopyData</tt> need to have a
- * working copy
- * constructor. <tt>ScratchData</tt>
- * is only used in the
- * <tt>worker</tt> function, while
- * <tt>CopyData</tt> is the object
- * passed from the <tt>worker</tt>
- * to the <tt>copier</tt>.
+ * The two data types <tt>ScratchData</tt> and <tt>CopyData</tt> need to
+ * have a working copy constructor. <tt>ScratchData</tt> is only used in the
+ * <tt>worker</tt> function, while <tt>CopyData</tt> is the object passed
+ * from the <tt>worker</tt> to the <tt>copier</tt>.
*
- * The @p queue_length argument indicates
- * the number of items that can be live
- * at any given time. Each item consists
- * of @p chunk_size elements of the input
- * stream that will be worked on by the
- * worker and copier functions one after
- * the other on the same thread.
+ * The @p queue_length argument indicates the number of items that can be
+ * live at any given time. Each item consists of @p chunk_size elements of
+ * the input stream that will be worked on by the worker and copier
+ * functions one after the other on the same thread.
*
- * @note If your data objects are large,
- * or their constructors are expensive,
- * it is helpful to keep in mind
- * that <tt>queue_length</tt>
- * copies of the <tt>ScratchData</tt>
- * object and
- * <tt>queue_length*chunk_size</tt>
- * copies of the <tt>CopyData</tt>
- * object are generated.
+ * @note If your data objects are large, or their constructors are
+ * expensive, it is helpful to keep in mind that <tt>queue_length</tt>
+ * copies of the <tt>ScratchData</tt> object and
+ * <tt>queue_length*chunk_size</tt> copies of the <tt>CopyData</tt> object
+ * are generated.
*/
template <typename Worker,
typename Copier,
ExcMessage ("The chunk_size must be at least one."));
(void)chunk_size; // removes -Wunused-parameter warning in optimized mode
- // if no work then skip. (only use
- // operator!= for iterators since we may
- // not have an equality comparison
- // operator)
+ // if no work then skip. (only use operator!= for iterators since we may
+ // not have an equality comparison operator)
if (!(begin != end))
return;
for (Iterator i=begin; i!=end; ++i)
{
- if (static_cast<const std_cxx1x::function<void (const Iterator &,
- ScratchData &,
- CopyData &)> >(worker))
- worker (i, scratch_data, copy_data);
- if (static_cast<const std_cxx1x::function<void (const CopyData &)> >
- (copier))
- copier (copy_data);
+ // need to check if the function is not the zero function. To
+ // check zero-ness, create a C++ function out of it and check that
+ if (static_cast<const std_cxx1x::function<void (const Iterator &,
+ ScratchData &,
+ CopyData &)>& >(worker))
+ worker (i, scratch_data, copy_data);
+ if (static_cast<const std_cxx1x::function<void (const CopyData &)>& >
+ (copier))
+ copier (copy_data);
}
}
#ifdef DEAL_II_WITH_THREADS
/**
- * This is the main function of the
- * WorkStream concept, doing work as
- * described in the introduction to this
- * namespace.
+ * This is the main function of the WorkStream concept, doing work as
+ * described in the introduction to this namespace.
*
- * This is the function that can be used
- * for worker and copier objects that are
- * either pointers to non-member
- * functions or objects that allow to be
- * called with an operator(), for example
- * objects created by std::bind.
+ * This is the function that can be used for worker and copier objects that
+ * are either pointers to non-member functions or objects that allow to be
+ * called with an operator(), for example objects created by std::bind.
*
- * The argument passed as @p end must be
- * convertible to the same type as
- * @p begin, but doesn't have to be of the
- * same type itself. This allows to write
- * code like
- * <code>WorkStream().run(dof_handler.begin_active(),
- * dof_handler.end(), ...</code> where
- * the first is of type
- * DoFHandler::active_cell_iterator
- * whereas the second is of type
+ * The argument passed as @p end must be convertible to the same type as @p
+ * begin, but doesn't have to be of the same type itself. This allows to
+ * write code like <code>WorkStream().run(dof_handler.begin_active(),
+ * dof_handler.end(), ...</code> where the first is of type
+ * DoFHandler::active_cell_iterator whereas the second is of type
* DoFHandler::raw_cell_iterator.
*
- * The two data types
- * <tt>ScratchData</tt> and
- * <tt>CopyData</tt> need to have a
- * working copy
- * constructor. <tt>ScratchData</tt>
- * is only used in the
- * <tt>worker</tt> function, while
- * <tt>CopyData</tt> is the object
- * passed from the <tt>worker</tt>
- * to the <tt>copier</tt>.
+ * The two data types <tt>ScratchData</tt> and <tt>CopyData</tt> need to
+ * have a working copy constructor. <tt>ScratchData</tt> is only used in the
+ * <tt>worker</tt> function, while <tt>CopyData</tt> is the object passed
+ * from the <tt>worker</tt> to the <tt>copier</tt>.
*
- * The @p get_conflict_indices argument, is a function
- * that given an iterator computes the conflict indices
- * necessary for the graph_coloring. Graph coloring is
- * necessary to be able to copy the data in parallel. If
- * the number of elements in some colors is less than
- * @p chunk_size time multithread_info.n_threads(),
- * these elements are aggregated and copied serially.
+ * The @p get_conflict_indices argument, is a function that given an
+ * iterator computes the conflict indices necessary for the
+ * graph_coloring. Graph coloring is necessary to be able to copy the data
+ * in parallel. If the number of elements in some colors is less than @p
+ * chunk_size time multithread_info.n_threads(), these elements are
+ * aggregated and copied serially.
*
- * The @p queue_length argument indicates
- * the number of items that can be live
- * at any given time. Each item consists
- * of @p chunk_size elements of the input
- * stream that will be worked on by the
- * worker and copier functions one after
- * the other on the same thread.
+ * The @p queue_length argument indicates the number of items that can be
+ * live at any given time. Each item consists of @p chunk_size elements of
+ * the input stream that will be worked on by the worker and copier
+ * functions one after the other on the same thread.
*
- * @note If your data objects are large,
- * or their constructors are expensive,
- * it is helpful to keep in mind
- * that <tt>queue_length</tt>
- * copies of the <tt>ScratchData</tt>
- * object and
- * <tt>queue_length*chunk_size</tt>
- * copies of the <tt>CopyData</tt>
- * object are generated.
+ * @note If your data objects are large, or their constructors are
+ * expensive, it is helpful to keep in mind that <tt>queue_length</tt>
+ * copies of the <tt>ScratchData</tt> object and
+ * <tt>queue_length*chunk_size</tt> copies of the <tt>CopyData</tt> object
+ * are generated.
*/
template <typename Worker,
typename Copier,
{
if (static_cast<const std_cxx1x::function<void (const Iterator &,
ScratchData &,
- CopyData &)> >(worker))
+ CopyData &)>& >(worker))
worker (i, scratch_data, copy_data);
- if (static_cast<const std_cxx1x::function<void (const CopyData &)> >
+ if (static_cast<const std_cxx1x::function<void (const CopyData &)>& >
(copier))
copier (copy_data);
}
/**
- * This is the main function of the
- * WorkStream concept, doing work as
- * described in the introduction to this
- * namespace.
+ * This is the main function of the WorkStream concept, doing work as
+ * described in the introduction to this namespace.
*
- * This is the function that can be
- * used for worker and copier functions
+ * This is the function that can be used for worker and copier functions
* that are member functions of a class.
*
- * The argument passed as @p end must be
- * convertible to the same type as
- * @p begin, but doesn't have to be of the
- * same type itself. This allows to write
- * code like
- * <code>WorkStream().run(dof_handler.begin_active(),
- * dof_handler.end(), ...</code> where
- * the first is of type
- * DoFHandler::active_cell_iterator
- * whereas the second is of type
+ * The argument passed as @p end must be convertible to the same type as @p
+ * begin, but doesn't have to be of the same type itself. This allows to
+ * write code like <code>WorkStream().run(dof_handler.begin_active(),
+ * dof_handler.end(), ...</code> where the first is of type
+ * DoFHandler::active_cell_iterator whereas the second is of type
* DoFHandler::raw_cell_iterator.
*
- * The @p queue_length argument indicates
- * the number of items that can be live
- * at any given time. Each item consists
- * of @p chunk_size elements of the input
- * stream that will be worked on by the
- * worker and copier functions one after
- * the other on the same thread.
+ * The @p queue_length argument indicates the number of items that can be
+ * live at any given time. Each item consists of @p chunk_size elements of
+ * the input stream that will be worked on by the worker and copier
+ * functions one after the other on the same thread.
*
- * @note If your data objects are large,
- * or their constructors are expensive,
- * it is helpful to keep in mind
- * that <tt>queue_length</tt>
- * copies of the <tt>ScratchData</tt>
- * object and
- * <tt>queue_length*chunk_size</tt>
- * copies of the <tt>CopyData</tt>
- * object are generated.
+ * @note If your data objects are large, or their constructors are
+ * expensive, it is helpful to keep in mind that <tt>queue_length</tt>
+ * copies of the <tt>ScratchData</tt> object and
+ * <tt>queue_length*chunk_size</tt> copies of the <tt>CopyData</tt> object
+ * are generated.
*/
template <typename MainClass,
typename Iterator,
/**
- * This is the main function of the
- * WorkStream concept, doing work as
- * described in the introduction to this
- * namespace.
+ * This is the main function of the WorkStream concept, doing work as
+ * described in the introduction to this namespace.
*
- * This is the function that can be
- * used for worker and copier functions
+ * This is the function that can be used for worker and copier functions
* that are member functions of a class.
*
- * The argument passed as @p end must be
- * convertible to the same type as
- * @p begin, but doesn't have to be of the
- * same type itself. This allows to write
- * code like
- * <code>WorkStream().run(dof_handler.begin_active(),
- * dof_handler.end(), ...</code> where
- * the first is of type
- * DoFHandler::active_cell_iterator
- * whereas the second is of type
+ * The argument passed as @p end must be convertible to the same type as @p
+ * begin, but doesn't have to be of the same type itself. This allows to
+ * write code like <code>WorkStream().run(dof_handler.begin_active(),
+ * dof_handler.end(), ...</code> where the first is of type
+ * DoFHandler::active_cell_iterator whereas the second is of type
* DoFHandler::raw_cell_iterator.
*
- * The @p get_conflict_indices argument, is a function
- * that given an iterator computes the conflict indices
- * necessary for the graph_coloring. Graph coloring is
- * necessary to be able to copy the data in parallel. If
- * the number of elements in some colors is less than
- * @p chunk_size time multithread_info.n_threads(),
- * these elements are aggregated and copied serially.
+ * The @p get_conflict_indices argument, is a function that given an
+ * iterator computes the conflict indices necessary for the
+ * graph_coloring. Graph coloring is necessary to be able to copy the data
+ * in parallel. If the number of elements in some colors is less than @p
+ * chunk_size time multithread_info.n_threads(), these elements are
+ * aggregated and copied serially.
*
- * The @p queue_length argument indicates
- * the number of items that can be live
- * at any given time. Each item consists
- * of @p chunk_size elements of the input
- * stream that will be worked on by the
- * worker and copier functions one after
- * the other on the same thread.
+ * The @p queue_length argument indicates the number of items that can be
+ * live at any given time. Each item consists of @p chunk_size elements of
+ * the input stream that will be worked on by the worker and copier
+ * functions one after the other on the same thread.
*
- * @note If your data objects are large,
- * or their constructors are expensive,
- * it is helpful to keep in mind
- * that <tt>queue_length</tt>
- * copies of the <tt>ScratchData</tt>
- * object and
- * <tt>queue_length*chunk_size</tt>
- * copies of the <tt>CopyData</tt>
- * object are generated.
+ * @note If your data objects are large, or their constructors are
+ * expensive, it is helpful to keep in mind that <tt>queue_length</tt>
+ * copies of the <tt>ScratchData</tt> object and
+ * <tt>queue_length*chunk_size</tt> copies of the <tt>CopyData</tt> object
+ * are generated.
*/
template <typename MainClass,
typename Iterator,