parallel_for_each.h Source File

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# parallel_for_each.h

    00001 /*
    00002     Copyright 2005-2010 Intel Corporation.  All Rights Reserved.
    00003
    00004     The source code contained or described herein and all documents related
    00005     to the source code ("Material") are owned by Intel Corporation or its
    00006     suppliers or licensors.  Title to the Material remains with Intel
    00007     Corporation or its suppliers and licensors.  The Material is protected
    00008     by worldwide copyright laws and treaty provisions.  No part of the
    00009     Material may be used, copied, reproduced, modified, published, uploaded,
    00010     posted, transmitted, distributed, or disclosed in any way without
    00011     Intel's prior express written permission.
    00012
    00013     No license under any patent, copyright, trade secret or other
    00014     intellectual property right is granted to or conferred upon you by
    00015     disclosure or delivery of the Materials, either expressly, by
    00016     implication, inducement, estoppel or otherwise.  Any license under such
    00017     intellectual property rights must be express and approved by Intel in
    00018     writing.
    00019 */
    00020
    00021 #ifndef __TBB_parallel_for_each_H
    00022 #define __TBB_parallel_for_each_H
    00023
    00024 #include "parallel_do.h"
    00025
    00026 namespace tbb {
    00027
    00029 namespace internal {
    00030     // The class calls user function in operator()
    00031     template <typename Function, typename Iterator>
    00032     class parallel_for_each_body : internal::no_assign {
    00033         const Function &my_func;
    00034     public:
    00035         parallel_for_each_body(const Function &_func) : my_func(_func) {}
    00036         parallel_for_each_body(const parallel_for_each_body<Function, Iterator> &_caller) : my_func(_caller.my_func) {}
    00037
    00038         void operator() ( typename std::iterator_traits<Iterator>::value_type& value ) const {
    00039             my_func(value);
    00040         }
    00041     };
    00042 } // namespace internal
    00044
    00048
    00049
    00050 template<typename InputIterator, typename Function>
    00051 void parallel_for_each(InputIterator first, InputIterator last, const Function& f, task_group_context &context) {
    00052     internal::parallel_for_each_body<Function, InputIterator> body(f);
    00053
    00054     tbb::parallel_do (first, last, body, context);
    00055 }
    00056
    00058 template<typename InputIterator, typename Function>
    00059 void parallel_for_each(InputIterator first, InputIterator last, const Function& f) {
    00060     internal::parallel_for_each_body<Function, InputIterator> body(f);
    00061
    00062     tbb::parallel_do (first, last, body);
    00063 }
    00064
    00066
    00067 } // namespace
    00068
    00069 #endif /* __TBB_parallel_for_each_H */

Copyright © 2005-2010 Intel Corporation. All Rights Reserved.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.