Skip to content

Commit

Permalink
actual code changes and additions for pthread api
Browse files Browse the repository at this point in the history
  • Loading branch information
friedmud committed Jul 22, 2013
1 parent 2bdd4cc commit 8612184
Show file tree
Hide file tree
Showing 4 changed files with 701 additions and 4 deletions.
33 changes: 33 additions & 0 deletions include/geom/stored_range.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,39 @@ class StoredRange
// specifically, do *not* copy the vector
}

/**
* NOTE: When using pthreads this constructor is MANDATORY!!!
*
* Copy constructor. The \p StoredRange can be copied into
* subranges for parallel execution. In this way the
* initial \p StoredRange can be thought of as the root of
* a binary tree. The root element is the only element
* which interacts with the user. It takes a specified
* range of objects and packs it into a contiguous vector
* which can be split efficiently. However, there is no need
* for the child ranges to contain this vector, so long as
* the parent outlives the children. So we implement
* the copy constructor to specifically omit the \p _objs
* vector. This version allows you to set the beginning and
* ending of this new range to be different from that of the
* one we're copying.
*/
StoredRange (const StoredRange<iterator_type,object_type> &er,
const const_iterator &begin,
const const_iterator &end):
_end(end),
_begin(begin),
_last(0), // Initialize these in a moment
_first(0),
_grainsize(er._grainsize),
_objs()
{
// specifically, do *not* copy the vector

_first = std::distance(er._begin, _begin);
_last = _first + std::distance(_begin, _end);
}

/**
* Splits the range \p r. The first half
* of the range is left in place, the second
Expand Down
Loading

0 comments on commit 8612184

Please sign in to comment.