1 #ifndef LIBJMMCG_CORE_PRIVATE_THREAD_DSEL_TYPES_HPP
2 #define LIBJMMCG_CORE_PRIVATE_THREAD_DSEL_TYPES_HPP
22 #include "../../core/config.h"
24 #include <boost/bind/bind.hpp>
26 #include <type_traits>
65 typename TPB::thread_traits::api_params_type::priority_type Pri,
327 struct parallel_algorithm
final :
public Alg {
338 template<
class BindFn>
356 operator<(BindFn1
const &)
const noexcept(
true) {
365 template<
class BindFn>
383 operator<(BindFn1
const &)
const noexcept(
true) {
406 template<
template<
class>
class Joinability,
class TPB,
typename TPB::priority_type Pri>
470 template<
class,
class,
class>
class B,
514 template<
class InpWk>
534 template<
class,
class,
class>
class B,
545 template<
class InpWk>
591 push_back(parallel_algorithm<Alg> &&wk)
noexcept(
false) {
592 return base_t::push_back(
std::forward<parallel_algorithm<Alg>>(wk));
597 operator<<(parallel_algorithm<Alg> &&wk)
noexcept(
false) {
598 return push_back(
std::forward<parallel_algorithm<Alg>>(wk));
602 template<
class InpWk>
606 template<
class InpWk>
608 operator<<(InpWk &&)=
delete;
624 template<
class InpWk>
641 push_back(parallel_algorithm<Alg> &&wk)
noexcept(
false) {
646 template<
class InpWk>
648 operator<<(InpWk &&)=
delete;
652 operator<<(parallel_algorithm<Alg> &&wk)
noexcept(
false) {
653 return push_back(
std::forward<parallel_algorithm<Alg>>(wk));
668 : pool(), num_cliques(c), cfg_parms(
"joinable") {
672 : pool(), num_cliques(c), cfg_parms(parent, details) {
675 : pool(&p), num_cliques(c), cfg_parms(pool->cfg(), cfg_p) {
678 : pool(&p), num_cliques(j.num_cliques), cfg_parms(pool->cfg(), j.cfg_parms) {
694 template<
class InpWk>
697 typedef typename thread_pool_type::
template execution_context_stack<InpWk> exec_ctx_t;
699 return exec_ctx_t(*pool, cfg_parms,
std::forward<InpWk>(wk));
708 push_back(parallel_algorithm<Alg> &&wk)
noexcept(
false) {
709 return wk.process(num_cliques, cfg_parms);
718 operator<<(
boost::_bi::bind_t<R, F, L> &&wk)
noexcept(
false) {
723 template<
class,
class,
class>
class B,
727 class Test=
typename std::enable_if<std::is_bind_expression<B<R, F, L>>::value>::type
730 operator<<(B<R, F, L> &&wk)
noexcept(
false) {
734 template<
class InpWk>
736 operator<<(InpWk &&wk)
noexcept(
false) {
737 typedef typename thread_pool_type::
template execution_context_stack<InpWk> exec_ctx_t;
739 return exec_ctx_t(*pool, cfg_parms,
std::move(wk));
743 operator<<(parallel_algorithm<Alg> &&wk)
noexcept(
false) {
744 return push_back(
std::forward<parallel_algorithm<Alg>>(wk));
757 operator<<(
typename thread_pool_type::
template priority<Pri>)
noexcept(
true) {
758 return priority_t<joinable_t, TPB, Pri>(*pool, cfg_parms);
768 operator<<(
cliques &&c)
noexcept(
true) {
775 typename pool_traits_type::thread_wk_elem_type::cfg_details_type::params
const cfg_parms;
789 : pool(), num_cliques(c), cfg_parms(
"nonjoinable") {
793 : pool(), num_cliques(c), cfg_parms(parent, details) {
796 : pool(&p), num_cliques(c), cfg_parms(pool->cfg(), cfg_p) {
799 : pool(&p), num_cliques(nj.num_cliques), cfg_parms(pool->cfg(), nj.cfg_parms) {
815 template<
class InpWk>
821 assert(
dynamic_cast<thread_pool_type *>(pool));
823 pool->add_nonjoinable_work(
825 new thread_wk_t(
typename creator_t::closure_t::argument_type(
std::forward<InpWk>(wk)), cfg_parms)
835 push_back(parallel_algorithm<Alg> &&wk)
noexcept(
false) {
836 return wk.process(num_cliques, cfg_parms);
839 template<
class R,
class F,
class L>
841 operator<<(
boost::_bi::bind_t<R, F, L> &&wk)
noexcept(
false) {
846 template<
class,
class,
class>
class B,
850 class Test=
typename std::enable_if<std::is_bind_expression<B<R, F, L>>::value>::type
853 operator<<(B<R, F, L> &&wk)
noexcept(
false) {
857 template<
class InpWk>
859 operator<<(InpWk &&wk)
noexcept(
false) {
860 return push_back(
std::forward<InpWk>(wk));
864 operator<<(parallel_algorithm<Alg> &&wk)
noexcept(
false) {
865 return push_back(
std::forward<parallel_algorithm<Alg>>(wk));
878 operator<<(
typename thread_pool_type::
template priority<Pri>)
noexcept(
true) {
879 return priority_t<nonjoinable_t, TPB, Pri>(*pool, cfg_parms);
896 typename pool_traits_type::thread_wk_elem_type::cfg_details_type::params
const cfg_parms;
919 : buffer(b), pool(), cfg_parms(
"nonjoinable_buff") {
923 : buffer(b), pool(), cfg_parms(parent, details) {
926 : buffer(njb.buffer), pool(&p), cfg_parms(pool->cfg(), njb.cfg_parms) {
942 template<
class InpWk>
948 assert(
dynamic_cast<thread_pool_type *>(pool));
949 assert(std::accumulate(buffer, buffer+
sizeof(thread_wk_t), 0UL)==0UL);
951 pool->add_nonjoinable_work(
953 new (buffer) thread_wk_t(
typename creator_t::closure_t::argument_type(
std::forward<InpWk>(wk)), cfg_parms)
959 template<
class InpWk>
961 operator<<(InpWk &&wk)
noexcept(
false) {
962 return push_back(
std::forward<InpWk>(wk));
968 typename pool_traits_type::thread_wk_elem_type::cfg_details_type::params
const cfg_parms;