1 #ifndef LIBJMMCG_CORE_PRIVATE_THREAD_POOL_BASE_HPP
2 #define LIBJMMCG_CORE_PRIVATE_THREAD_POOL_BASE_HPP
23 #include "../../core/thread_pool_aspects.hpp"
25 #include "../../core/thread_statistics.hpp"
29 static constexpr char const node_details_acc_op[]=
"accumulate_op";
30 static constexpr char const node_details_acc[]=
"accumulate";
31 static constexpr char const max_element_str[]=
"max_element";
32 static constexpr char const min_element_str[]=
"min_element";
34 template<
class V,
class>
38 template<
class V,
class LkT>
65 class thread_pool_base;
73 class thread_pool_base {
78 static constexpr unsigned short init_num_jobs_par_alg=1;
79 static constexpr unsigned short init_num_jobs_par_alg_other=0;
83 static constexpr unsigned short default_num_subranges=1;
86 using pool_traits_type=PTT;
88 using pool_size_type=
typename pool_type::size_type;
89 using pool_thread_type=
typename remove_shared_ptr<
typename pool_type::value_type, api_lock_traits<platform_api, sequential_mode>>::value_type;
91 using os_traits=
typename pool_traits_type::os_traits;
98 using exception_type=
typename os_traits::exception_type;
100 using thread_traits=
typename os_traits::thread_traits;
102 using api_params_type=
typename thread_traits::api_params_type;
104 using priority_type=
typename api_params_type::priority_type;
105 using work_distribution_mode=DM;
106 using pool_thread_queue_details=
typename pool_traits_type::
template pool_thread_queue_details<
typename work_distribution_mode::queue_model>;
107 using statistics_type=
typename pool_thread_queue_details::statistics_type;
108 using signalled_work_queue_type=
typename pool_traits_type::
template signalled_work_queue_type<
typename work_distribution_mode::queue_model>;
109 using queue_size_type=
typename signalled_work_queue_type::size_type;
121 using cfg_type=
typename pool_traits_type::cfg_type;
154 template<
class InpWk>
155 struct execution_context_stack;
162 class PtrFnType=
decltype(&
std::remove_reference<InpWk>::type::process)
164 struct create_direct;
255 class transform_iter_t;
276 struct map_red_initialiser;
287 template<
class,
class>
class Reduce,
301 struct max_element_initialiser;
311 struct min_element_initialiser;
323 struct accumulate_op_processor;
335 struct accumulate_processor;
345 class Comp=
std::less<
typename Colln::value_type>
347 struct max_element_t;
356 class Comp=
std::less<
typename Colln::value_type>
358 struct min_element_t;
464 virtual const pool_size_type
__fastcall pool_size()
const noexcept(
true)=0;
474 virtual const queue_size_type
__fastcall queue_size()
const noexcept(
true)=0;
483 virtual statistics_type
const __fastcall statistics()
const =0;
498 virtual unsigned long __fastcall
513 virtual unsigned long __fastcall
524 template<priority_type Pri>
537 operator<<(nonjoinable &&nj)
noexcept(
true) {
538 return nonjoinable(
std::forward<nonjoinable>(nj), *
this);
550 operator<<(nonjoinable_buff &&njb)
noexcept(
true) {
551 return nonjoinable_buff(
std::forward<nonjoinable_buff>(njb), *
this);
561 operator<<(
joinable_t<thread_pool_base> &&j)
noexcept(
true) {
586 > parallel_algorithm<for_each_t<Colln, Fn> >
__fastcall FORCE_INLINE
609 > parallel_algorithm<count_if_t<Colln, Pred> >
__fastcall FORCE_INLINE
623 > parallel_algorithm<count_t<Colln> >
__fastcall FORCE_INLINE
624 count(Colln
const &c,
typename Colln::value_type
const &v);
646 > parallel_algorithm<find_if_t<Colln, Pred> >
__fastcall FORCE_INLINE
660 > parallel_algorithm<find_t<Colln> >
__fastcall FORCE_INLINE
661 find(Colln
const &c,
typename Colln::value_type
const &v);
687 > parallel_algorithm<transform_t<CollnIn, CollnOut, UniOp> >
__fastcall FORCE_INLINE
688 transform(CollnIn
const &in, CollnOut &out, UniOp
const &uniop);
716 > parallel_algorithm<transform2_t<CollnIn1, CollnIn2, CollnOut, BinOp> >
__fastcall FORCE_INLINE
717 transform(CollnIn1
const &in1, CollnIn2
const &in2, CollnOut &out, BinOp
const &binop);
736 copy(CollnIn
const &in, CollnOut &out);
755 > parallel_algorithm<accumulate_op_processor<Colln, BinOp> >
__fastcall FORCE_INLINE
756 accumulate(Colln
const &c,
typename BinOp::result_type
const &v, BinOp
const &binop);
769 > parallel_algorithm<accumulate_processor<Colln, V>>
__fastcall FORCE_INLINE
793 > parallel_algorithm<fill_n_t<Colln> >
__fastcall FORCE_INLINE
794 fill_n(Colln &c,
typename Colln::size_type sz,
typename Colln::value_type
const &v);
816 > parallel_algorithm<fill_t<Colln> >
__fastcall FORCE_INLINE
817 fill(Colln &c,
typename Colln::value_type
const &v);
838 > parallel_algorithm<reverse_t<Colln> >
__fastcall FORCE_INLINE
854 > parallel_algorithm<max_element_t<Colln, Comp>>
__fastcall FORCE_INLINE
884 > parallel_algorithm<min_element_t<Colln, Comp>>
__fastcall FORCE_INLINE
928 > parallel_algorithm<merge_t<CollnIn1, CollnIn2, CollnOut, Compare> >
__fastcall FORCE_INLINE
929 merge(CollnIn1
const &in1, CollnIn2
const &in2, CollnOut &out, Compare
const &comp);
944 > parallel_algorithm<merge_t<CollnIn1, CollnIn2, CollnOut,
std::less<
typename CollnOut::
value_type> > >
__fastcall FORCE_INLINE
945 merge(CollnIn1
const &in1, CollnIn2
const &in2, CollnOut &out);
972 > parallel_algorithm<sort_t<Colln, Compare> >
__fastcall FORCE_INLINE
973 sort(Colln &c, Compare
const &comp);
1079 operator<<(
tostream &os, thread_pool_base<DM1, Ps1, PTT1, Pt1>
const &t);
1112 > parallel_algorithm<swap_ranges_t<Colln, Pred> >
__fastcall FORCE_INLINE
1113 swap_ranges(
typename Colln::container_type::iterator b1,
typename Colln::container_type::iterator e1,
typename Colln::container_type::iterator b2, Pred
const &p);
1137 > parallel_algorithm<transform_iter_t<CollnIn, CollnOut, IterIn, UniOp> >
__fastcall FORCE_INLINE
1138 transform(IterIn b1, IterIn e1,
typename CollnOut::container_type::iterator b2, UniOp
const &uniop);
1160 > parallel_algorithm<copy_iter_t<CollnIn, CollnOut, IterIn> >
__fastcall FORCE_INLINE
1161 copy(IterIn b1, IterIn e1,
typename CollnOut::container_type::iterator b2);
1168 thread_traits::set_backtrace_on_signal();
1169 thread_traits::set_backtrace_on_terminate();
1175 virtual signalled_work_queue_type &
__fastcall queue()
noexcept(
true)=0;
1176 virtual signalled_work_queue_type
const &
__fastcall queue()
const noexcept(
true)=0;
1179 virtual typename signalled_work_queue_type::
value_type __fastcall add_joinable_work(
typename signalled_work_queue_type::value_type &&)
noexcept(
false)=0;
1184 virtual bool __fastcall process_a_batch_item(
const typename thread_traits::api_params_type::tid_type,
typename os_traits::thread_exception
const &)
noexcept(
false)
FORCE_INLINE {
1188 template<
class ExecCtx>
1190 make_arg(
typename signalled_work_queue_type::value_type &&async_wk) {
1191 return ExecCtx::
template make_arg<
typename ExecCtx::result_type>(
1192 std::forward<
typename signalled_work_queue_type::value_type>(async_wk),
1203 template<
template<
class>
class Joinability,
class TPB,
typename TPB::priority_type Pri>
friend class priority_t;