13 #ifndef STXXL_RUN_CURSOR_HEADER
14 #define STXXL_RUN_CURSOR_HEADER
16 #include <stxxl/bits/common/utils.h>
19 __STXXL_BEGIN_NAMESPACE
21 template <
typename block_type>
27 run_cursor() : pos(0), buffer(NULL) { }
29 inline const typename block_type::type & current()
const
31 return (*buffer)[pos];
33 inline void operator ++ (
int)
39 #ifdef STXXL_SORT_SINGLE_PREFETCHER
41 template <
typename must_be_
void =
void>
42 struct have_prefetcher
44 static void * untyped_prefetcher;
49 template <
typename block_type,
50 typename prefetcher_type_>
51 struct run_cursor2 :
public run_cursor<block_type>
52 #ifdef STXXL_SORT_SINGLE_PREFETCHER
53 ,
public have_prefetcher<>
56 typedef prefetcher_type_ prefetcher_type;
57 typedef run_cursor2<block_type, prefetcher_type> _Self;
58 typedef typename block_type::value_type value_type;
61 using run_cursor<block_type>::pos;
62 using run_cursor<block_type>::buffer;
64 #ifdef STXXL_SORT_SINGLE_PREFETCHER
65 static prefetcher_type *
const prefetcher()
67 return reinterpret_cast<prefetcher_type *
>(untyped_prefetcher);
69 static void set_prefetcher(prefetcher_type * pfptr)
71 untyped_prefetcher = pfptr;
75 prefetcher_type * prefetcher_;
76 prefetcher_type * & prefetcher()
82 run_cursor2(prefetcher_type * p) : prefetcher_(p) { }
85 inline bool empty()
const
87 return (pos >= block_type::size);
89 inline void operator ++ (
int);
90 inline void make_inf()
92 pos = block_type::size;
96 #ifdef STXXL_SORT_SINGLE_PREFETCHER
97 template <
typename must_be_
void>
98 void * have_prefetcher<must_be_void>::untyped_prefetcher = NULL;
101 template <
typename block_type,
102 typename prefetcher_type>
103 void run_cursor2<block_type, prefetcher_type>::operator ++ (
int)
107 if (UNLIKELY(pos >= block_type::size))
109 if (prefetcher()->block_consumed(buffer))
115 template <
typename block_type>
116 struct run_cursor_cmp
118 typedef run_cursor<block_type> cursor_type;
126 __STXXL_END_NAMESPACE
129 #endif // !STXXL_RUN_CURSOR_HEADER