// -*- C++ -*-
-// Copyright (C) 2007 Free Software Foundation, Inc.
+// Copyright (C) 2007, 2008 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
* std::count_n()).
* @return User-supplied functor (that may contain a part of the result).
*/
-template<
- typename RandomAccessIterator,
- typename Op,
- typename Fu,
- typename Red,
- typename Result>
+template<typename RandomAccessIterator,
+ typename Op,
+ typename Fu,
+ typename Red,
+ typename Result>
Op
- for_each_template_random_access_workstealing(
- RandomAccessIterator begin,
- RandomAccessIterator end,
- Op op, Fu& f, Red r,
- Result base, Result& output,
- typename std::iterator_traits<RandomAccessIterator>::difference_type
- bound)
+ for_each_template_random_access_workstealing(RandomAccessIterator begin,
+ RandomAccessIterator end,
+ Op op, Fu& f, Red r,
+ Result base, Result& output,
+ typename std::iterator_traits
+ <RandomAccessIterator>::
+ difference_type bound)
{
_GLIBCXX_CALL(end - begin)
// This thread is currently working.
# pragma omp atomic
- busy++;
+ ++busy;
iam_working = true;
// Cannot use volatile variable directly.
difference_type my_first = my_job.first;
result = f(op, begin + my_first);
- my_job.first++;
- my_job.load--;
+ ++my_job.first;
+ --my_job.load;
}
RandomAccessIterator current;
my_job.load = my_job.last - my_job.first + 1;
for (difference_type job_counter = 0;
job_counter < chunk_size && current_job <= my_job.last;
- job_counter++)
+ ++job_counter)
{
// Yes: process it!
current = begin + current_job;
- current_job++;
+ ++current_job;
// Do actual work.
result = r(result, f(op, current));
{
// This thread no longer has work.
# pragma omp atomic
- busy--;
+ --busy;
iam_working = false;
}
// Has potential work again.
# pragma omp atomic
- busy++;
+ ++busy;
iam_working = true;
# pragma omp flush(busy)