Check out the new USENIX Web site. next up previous contents
Next: Example of a Parallel Up: Strategies Previous: Requirements of a Strategy

Strategy Categories and Tags

Coir<Futures> strategy classes are derived from two base classes - static_strategy and dynamic_strategy. These two classes are empty classes (similar to input_iterator, output_iterator, etc., classes). Also we define a strategy tag corresponding to each strategy class (similar to iterator tags in STL) which can be used to provide implementations specific to different strategies. The strategy tag for any strategy class S can be obtained from the strategy_category function:

 ES_category_tag strategy_category(const S&
strategy)

{

return S_strategy_tag();

}

If an algorithm, say transpose, has different implementations for the Block and Cyclic strategies (either for the reasons of efficiency or for correctness) it can be implemented as:
 template <class Strategy, class InputIterator>

OutputIterator transpose(Strategy& strategy,

InputIterator first,

InputIterator last)

{

return transpose(strategy, first, last,

strategy_category(strategy));

}

template <class Strategy, class InputIterator>

OutputIterator transpose(Strategy& strategy,

InputIterator first,

InputIterator last,

block_strategy_tag btag)

{

code specific to Block strategy

}

template <class Strategy, class InputIterator>

OutputIterator transpose(Strategy& strategy,

InputIterator first,

InputIterator last,

cyclic_strategy_tag ctag)

{

code specific to Cyclic strategy

}



Sundaresan Neelakantan
Thu May 15 16:11:49 PDT 1997