16 #ifndef dealii__thread_management_h 17 #define dealii__thread_management_h 20 #include <deal.II/base/config.h> 21 #include <deal.II/base/exceptions.h> 22 #include <deal.II/base/template_constraints.h> 23 #include <deal.II/base/std_cxx11/tuple.h> 24 #include <deal.II/base/std_cxx11/function.h> 25 #include <deal.II/base/std_cxx11/shared_ptr.h> 26 #include <deal.II/base/std_cxx11/bind.h> 28 #ifdef DEAL_II_WITH_THREADS 29 # include <deal.II/base/std_cxx11/thread.h> 30 # include <deal.II/base/std_cxx11/mutex.h> 31 # include <deal.II/base/std_cxx11/condition_variable.h> 40 #ifdef DEAL_II_WITH_THREADS 41 # ifdef DEAL_II_USE_MT_POSIX 44 # include <tbb/task.h> 45 # include <tbb/tbb_stddef.h> 50 DEAL_II_NAMESPACE_OPEN
196 const char *name = 0,
223 <<
"In single-thread mode, barrier sizes other than 1 are not " 224 <<
"useful. You gave " << arg1 <<
".");
230 #ifdef DEAL_II_WITH_THREADS 386 std_cxx11::unique_lock<std_cxx11::mutex> lock(mutex.
mutex,
387 std_cxx11::adopt_lock);
421 const char *name = 0,
442 #ifndef DEAL_II_USE_MT_POSIX_NO_BARRIERS 543 template <
typename ForwardIterator>
544 std::vector<std::pair<ForwardIterator,ForwardIterator> >
546 const ForwardIterator &end,
547 const unsigned int n_intervals);
557 std::vector<std::pair<unsigned int,unsigned int> >
559 const unsigned int end,
560 const unsigned int n_intervals);
590 void handle_std_exception (
const std::exception &exc);
599 void handle_unknown_exception ();
608 void register_thread ();
617 void deregister_thread ();
630 template <
typename ForwardIterator>
631 std::vector<std::pair<ForwardIterator,ForwardIterator> >
633 const ForwardIterator &end,
634 const unsigned int n_intervals)
636 typedef std::pair<ForwardIterator,ForwardIterator> IteratorPair;
643 return (std::vector<IteratorPair>
644 (1, IteratorPair(begin, end)));
647 const unsigned int n_elements = std::distance (begin, end);
648 const unsigned int n_elements_per_interval = n_elements / n_intervals;
649 const unsigned int residual = n_elements % n_intervals;
651 std::vector<IteratorPair> return_values (n_intervals);
653 return_values[0].first = begin;
654 for (
unsigned int i=0; i<n_intervals; ++i)
656 if (i != n_intervals-1)
658 return_values[i].second = return_values[i].first;
663 std::advance (return_values[i].second,
664 static_cast<signed int>(n_elements_per_interval));
668 ++return_values[i].second;
670 return_values[i+1].first = return_values[i].second;
673 return_values[i].second = end;
675 return return_values;
692 template <
typename RT>
struct return_value
697 inline return_value () : value() {}
699 inline RT
get ()
const 704 inline void set (RT v)
720 template <
typename RT>
struct return_value<RT &>
725 inline return_value () : value(0) {}
727 inline RT &
get ()
const 731 inline void set (RT &v)
746 template <>
struct return_value<void>
748 static inline void get () {}
756 template <
typename RT>
757 inline void call (
const std_cxx11::function<RT ()> &
function,
758 internal::return_value<RT> &ret_val)
760 ret_val.set (
function());
764 inline void call (
const std_cxx11::function<
void ()> &
function,
765 internal::return_value<void> &)
784 template <
typename RT,
typename ArgList,
785 int length = std_cxx11::tuple_size<ArgList>::value>
786 struct fun_ptr_helper;
795 template <
typename RT,
typename ArgList>
796 struct fun_ptr_helper<RT, ArgList, 0>
798 typedef RT (type) ();
808 template <
typename RT,
typename ArgList>
809 struct fun_ptr_helper<RT, ArgList, 1>
811 typedef RT (type) (
typename std_cxx11::tuple_element<0,ArgList>::type);
821 template <
typename RT,
typename ArgList>
822 struct fun_ptr_helper<RT, ArgList, 2>
824 typedef RT (type) (
typename std_cxx11::tuple_element<0,ArgList>::type,
825 typename std_cxx11::tuple_element<1,ArgList>::type);
835 template <
typename RT,
typename ArgList>
836 struct fun_ptr_helper<RT, ArgList, 3>
838 typedef RT (type) (
typename std_cxx11::tuple_element<0,ArgList>::type,
839 typename std_cxx11::tuple_element<1,ArgList>::type,
840 typename std_cxx11::tuple_element<2,ArgList>::type);
850 template <
typename RT,
typename ArgList>
851 struct fun_ptr_helper<RT, ArgList, 4>
853 typedef RT (type) (
typename std_cxx11::tuple_element<0,ArgList>::type,
854 typename std_cxx11::tuple_element<1,ArgList>::type,
855 typename std_cxx11::tuple_element<2,ArgList>::type,
856 typename std_cxx11::tuple_element<3,ArgList>::type);
866 template <
typename RT,
typename ArgList>
867 struct fun_ptr_helper<RT, ArgList, 5>
869 typedef RT (type) (
typename std_cxx11::tuple_element<0,ArgList>::type,
870 typename std_cxx11::tuple_element<1,ArgList>::type,
871 typename std_cxx11::tuple_element<2,ArgList>::type,
872 typename std_cxx11::tuple_element<3,ArgList>::type,
873 typename std_cxx11::tuple_element<4,ArgList>::type);
883 template <
typename RT,
typename ArgList>
884 struct fun_ptr_helper<RT, ArgList, 6>
886 typedef RT (type) (
typename std_cxx11::tuple_element<0,ArgList>::type,
887 typename std_cxx11::tuple_element<1,ArgList>::type,
888 typename std_cxx11::tuple_element<2,ArgList>::type,
889 typename std_cxx11::tuple_element<3,ArgList>::type,
890 typename std_cxx11::tuple_element<4,ArgList>::type,
891 typename std_cxx11::tuple_element<5,ArgList>::type);
901 template <
typename RT,
typename ArgList>
902 struct fun_ptr_helper<RT, ArgList, 7>
904 typedef RT (type) (
typename std_cxx11::tuple_element<0,ArgList>::type,
905 typename std_cxx11::tuple_element<1,ArgList>::type,
906 typename std_cxx11::tuple_element<2,ArgList>::type,
907 typename std_cxx11::tuple_element<3,ArgList>::type,
908 typename std_cxx11::tuple_element<4,ArgList>::type,
909 typename std_cxx11::tuple_element<5,ArgList>::type,
910 typename std_cxx11::tuple_element<6,ArgList>::type);
920 template <
typename RT,
typename ArgList>
921 struct fun_ptr_helper<RT, ArgList, 8>
923 typedef RT (type) (
typename std_cxx11::tuple_element<0,ArgList>::type,
924 typename std_cxx11::tuple_element<1,ArgList>::type,
925 typename std_cxx11::tuple_element<2,ArgList>::type,
926 typename std_cxx11::tuple_element<3,ArgList>::type,
927 typename std_cxx11::tuple_element<4,ArgList>::type,
928 typename std_cxx11::tuple_element<5,ArgList>::type,
929 typename std_cxx11::tuple_element<6,ArgList>::type,
930 typename std_cxx11::tuple_element<7,ArgList>::type);
940 template <
typename RT,
typename ArgList>
941 struct fun_ptr_helper<RT, ArgList, 9>
943 typedef RT (type) (
typename std_cxx11::tuple_element<0,ArgList>::type,
944 typename std_cxx11::tuple_element<1,ArgList>::type,
945 typename std_cxx11::tuple_element<2,ArgList>::type,
946 typename std_cxx11::tuple_element<3,ArgList>::type,
947 typename std_cxx11::tuple_element<4,ArgList>::type,
948 typename std_cxx11::tuple_element<5,ArgList>::type,
949 typename std_cxx11::tuple_element<6,ArgList>::type,
950 typename std_cxx11::tuple_element<7,ArgList>::type,
951 typename std_cxx11::tuple_element<8,ArgList>::type);
962 template <
typename RT,
typename ArgList>
963 struct fun_ptr_helper<RT, ArgList, 10>
965 typedef RT (type) (
typename std_cxx11::tuple_element<0,ArgList>::type,
966 typename std_cxx11::tuple_element<1,ArgList>::type,
967 typename std_cxx11::tuple_element<2,ArgList>::type,
968 typename std_cxx11::tuple_element<3,ArgList>::type,
969 typename std_cxx11::tuple_element<4,ArgList>::type,
970 typename std_cxx11::tuple_element<5,ArgList>::type,
971 typename std_cxx11::tuple_element<6,ArgList>::type,
972 typename std_cxx11::tuple_element<7,ArgList>::type,
973 typename std_cxx11::tuple_element<8,ArgList>::type,
974 typename std_cxx11::tuple_element<9,ArgList>::type);
989 template <
typename RT,
typename ArgList>
992 typedef typename fun_ptr_helper<RT,ArgList>::type type;
1000 #ifdef DEAL_II_WITH_THREADS 1012 template <
typename RT>
1088 void start (
const std_cxx11::function<RT ()> &
function)
1091 ret_val.reset(
new return_value<RT>());
1123 std_cxx11::shared_ptr<return_value<RT> >
ret_val)
1130 internal::register_thread ();
1135 catch (
const std::exception &exc)
1137 internal::handle_std_exception (exc);
1141 internal::handle_unknown_exception ();
1143 internal::deregister_thread ();
1156 template <
typename RT>
1157 struct ThreadDescriptor
1163 std_cxx11::shared_ptr<return_value<RT> >
ret_val;
1169 void start (
const std_cxx11::function<RT ()> &
function)
1171 ret_val.reset(
new return_value<RT>());
1208 template <
typename RT =
void>
1215 Thread (
const std_cxx11::function<RT ()> &
function)
1299 template <
typename T>
1317 template <
typename T>
1320 static std_cxx11::reference_wrapper<T> act (T &t)
1322 return std_cxx11::ref(t);
1344 template <
typename RT,
typename ArgList,
int length>
1345 class fun_encapsulator;
1355 template <
typename RT,
typename ArgList>
1356 class fun_encapsulator<RT, ArgList, 0>
1359 fun_encapsulator (
typename internal::fun_ptr<RT,ArgList>::type *
function)
1360 : function (*function)
1363 fun_encapsulator (
const std_cxx11::function<
typename internal::fun_ptr<RT,ArgList>::type> &
function)
1364 : function (function)
1371 return Thread<RT> (
function);
1375 std_cxx11::function<typename internal::fun_ptr<RT,ArgList>::type>
function;
1383 template <
typename RT,
typename ArgList>
1384 class fun_encapsulator<RT, ArgList, 1>
1387 fun_encapsulator (
typename internal::fun_ptr<RT,ArgList>::type *
function)
1388 : function (*function)
1391 fun_encapsulator (
const std_cxx11::function<
typename internal::fun_ptr<RT,ArgList>::type> &
function)
1392 : function (function)
1397 operator() (
typename std_cxx11::tuple_element<0,ArgList>::type arg1)
1401 (std_cxx11::bind (
function,
1402 internal::maybe_make_ref<
typename std_cxx11::tuple_element<0,ArgList>::type>::act(arg1)));
1406 std_cxx11::function<typename internal::fun_ptr<RT,ArgList>::type>
function;
1414 template <
typename RT,
typename ArgList>
1415 class fun_encapsulator<RT, ArgList, 2>
1418 fun_encapsulator (
typename internal::fun_ptr<RT,ArgList>::type *
function)
1419 : function (*function)
1422 fun_encapsulator (
const std_cxx11::function<
typename internal::fun_ptr<RT,ArgList>::type> &
function)
1423 : function (function)
1428 operator() (
typename std_cxx11::tuple_element<0,ArgList>::type arg1,
1429 typename std_cxx11::tuple_element<1,ArgList>::type arg2)
1433 (std_cxx11::bind (
function,
1434 internal::maybe_make_ref<
typename std_cxx11::tuple_element<0,ArgList>::type>::act(arg1),
1435 internal::maybe_make_ref<
typename std_cxx11::tuple_element<1,ArgList>::type>::act(arg2)));
1439 std_cxx11::function<typename internal::fun_ptr<RT,ArgList>::type>
function;
1447 template <
typename RT,
typename ArgList>
1448 class fun_encapsulator<RT, ArgList, 3>
1451 fun_encapsulator (
typename internal::fun_ptr<RT,ArgList>::type *
function)
1452 : function (*function)
1455 fun_encapsulator (
const std_cxx11::function<
typename internal::fun_ptr<RT,ArgList>::type> &
function)
1456 : function (function)
1461 operator() (
typename std_cxx11::tuple_element<0,ArgList>::type arg1,
1462 typename std_cxx11::tuple_element<1,ArgList>::type arg2,
1463 typename std_cxx11::tuple_element<2,ArgList>::type arg3)
1467 (std_cxx11::bind (
function,
1468 internal::maybe_make_ref<
typename std_cxx11::tuple_element<0,ArgList>::type>::act(arg1),
1469 internal::maybe_make_ref<
typename std_cxx11::tuple_element<1,ArgList>::type>::act(arg2),
1470 internal::maybe_make_ref<
typename std_cxx11::tuple_element<2,ArgList>::type>::act(arg3)));
1474 std_cxx11::function<typename internal::fun_ptr<RT,ArgList>::type>
function;
1482 template <
typename RT,
typename ArgList>
1483 class fun_encapsulator<RT, ArgList, 4>
1486 fun_encapsulator (
typename internal::fun_ptr<RT,ArgList>::type *
function)
1487 : function (*function)
1490 fun_encapsulator (
const std_cxx11::function<
typename internal::fun_ptr<RT,ArgList>::type> &
function)
1491 : function (function)
1496 operator() (
typename std_cxx11::tuple_element<0,ArgList>::type arg1,
1497 typename std_cxx11::tuple_element<1,ArgList>::type arg2,
1498 typename std_cxx11::tuple_element<2,ArgList>::type arg3,
1499 typename std_cxx11::tuple_element<3,ArgList>::type arg4)
1503 (std_cxx11::bind (
function,
1504 internal::maybe_make_ref<
typename std_cxx11::tuple_element<0,ArgList>::type>::act(arg1),
1505 internal::maybe_make_ref<
typename std_cxx11::tuple_element<1,ArgList>::type>::act(arg2),
1506 internal::maybe_make_ref<
typename std_cxx11::tuple_element<2,ArgList>::type>::act(arg3),
1507 internal::maybe_make_ref<
typename std_cxx11::tuple_element<3,ArgList>::type>::act(arg4)));
1511 std_cxx11::function<typename internal::fun_ptr<RT,ArgList>::type>
function;
1519 template <
typename RT,
typename ArgList>
1520 class fun_encapsulator<RT, ArgList, 5>
1523 fun_encapsulator (
typename internal::fun_ptr<RT,ArgList>::type *
function)
1524 : function (*function)
1527 fun_encapsulator (
const std_cxx11::function<
typename internal::fun_ptr<RT,ArgList>::type> &
function)
1528 : function (function)
1533 operator() (
typename std_cxx11::tuple_element<0,ArgList>::type arg1,
1534 typename std_cxx11::tuple_element<1,ArgList>::type arg2,
1535 typename std_cxx11::tuple_element<2,ArgList>::type arg3,
1536 typename std_cxx11::tuple_element<3,ArgList>::type arg4,
1537 typename std_cxx11::tuple_element<4,ArgList>::type arg5)
1541 (std_cxx11::bind (
function,
1542 internal::maybe_make_ref<
typename std_cxx11::tuple_element<0,ArgList>::type>::act(arg1),
1543 internal::maybe_make_ref<
typename std_cxx11::tuple_element<1,ArgList>::type>::act(arg2),
1544 internal::maybe_make_ref<
typename std_cxx11::tuple_element<2,ArgList>::type>::act(arg3),
1545 internal::maybe_make_ref<
typename std_cxx11::tuple_element<3,ArgList>::type>::act(arg4),
1546 internal::maybe_make_ref<
typename std_cxx11::tuple_element<4,ArgList>::type>::act(arg5)));
1550 std_cxx11::function<typename internal::fun_ptr<RT,ArgList>::type>
function;
1558 template <
typename RT,
typename ArgList>
1559 class fun_encapsulator<RT, ArgList, 6>
1562 fun_encapsulator (
typename internal::fun_ptr<RT,ArgList>::type *
function)
1563 : function (*function)
1566 fun_encapsulator (
const std_cxx11::function<
typename internal::fun_ptr<RT,ArgList>::type> &
function)
1567 : function (function)
1572 operator() (
typename std_cxx11::tuple_element<0,ArgList>::type arg1,
1573 typename std_cxx11::tuple_element<1,ArgList>::type arg2,
1574 typename std_cxx11::tuple_element<2,ArgList>::type arg3,
1575 typename std_cxx11::tuple_element<3,ArgList>::type arg4,
1576 typename std_cxx11::tuple_element<4,ArgList>::type arg5,
1577 typename std_cxx11::tuple_element<5,ArgList>::type arg6)
1581 (std_cxx11::bind (
function,
1582 internal::maybe_make_ref<
typename std_cxx11::tuple_element<0,ArgList>::type>::act(arg1),
1583 internal::maybe_make_ref<
typename std_cxx11::tuple_element<1,ArgList>::type>::act(arg2),
1584 internal::maybe_make_ref<
typename std_cxx11::tuple_element<2,ArgList>::type>::act(arg3),
1585 internal::maybe_make_ref<
typename std_cxx11::tuple_element<3,ArgList>::type>::act(arg4),
1586 internal::maybe_make_ref<
typename std_cxx11::tuple_element<4,ArgList>::type>::act(arg5),
1587 internal::maybe_make_ref<
typename std_cxx11::tuple_element<5,ArgList>::type>::act(arg6)));
1591 std_cxx11::function<typename internal::fun_ptr<RT,ArgList>::type>
function;
1599 template <
typename RT,
typename ArgList>
1600 class fun_encapsulator<RT, ArgList, 7>
1603 fun_encapsulator (
typename internal::fun_ptr<RT,ArgList>::type *
function)
1604 : function (*function)
1607 fun_encapsulator (
const std_cxx11::function<
typename internal::fun_ptr<RT,ArgList>::type> &
function)
1608 : function (function)
1613 operator() (
typename std_cxx11::tuple_element<0,ArgList>::type arg1,
1614 typename std_cxx11::tuple_element<1,ArgList>::type arg2,
1615 typename std_cxx11::tuple_element<2,ArgList>::type arg3,
1616 typename std_cxx11::tuple_element<3,ArgList>::type arg4,
1617 typename std_cxx11::tuple_element<4,ArgList>::type arg5,
1618 typename std_cxx11::tuple_element<5,ArgList>::type arg6,
1619 typename std_cxx11::tuple_element<6,ArgList>::type arg7)
1623 (std_cxx11::bind (
function,
1624 internal::maybe_make_ref<
typename std_cxx11::tuple_element<0,ArgList>::type>::act(arg1),
1625 internal::maybe_make_ref<
typename std_cxx11::tuple_element<1,ArgList>::type>::act(arg2),
1626 internal::maybe_make_ref<
typename std_cxx11::tuple_element<2,ArgList>::type>::act(arg3),
1627 internal::maybe_make_ref<
typename std_cxx11::tuple_element<3,ArgList>::type>::act(arg4),
1628 internal::maybe_make_ref<
typename std_cxx11::tuple_element<4,ArgList>::type>::act(arg5),
1629 internal::maybe_make_ref<
typename std_cxx11::tuple_element<5,ArgList>::type>::act(arg6),
1630 internal::maybe_make_ref<
typename std_cxx11::tuple_element<6,ArgList>::type>::act(arg7)));
1634 std_cxx11::function<typename internal::fun_ptr<RT,ArgList>::type>
function;
1642 template <
typename RT,
typename ArgList>
1643 class fun_encapsulator<RT, ArgList, 8>
1646 fun_encapsulator (
typename internal::fun_ptr<RT,ArgList>::type *
function)
1647 : function (*function)
1650 fun_encapsulator (
const std_cxx11::function<
typename internal::fun_ptr<RT,ArgList>::type> &
function)
1651 : function (function)
1656 operator() (
typename std_cxx11::tuple_element<0,ArgList>::type arg1,
1657 typename std_cxx11::tuple_element<1,ArgList>::type arg2,
1658 typename std_cxx11::tuple_element<2,ArgList>::type arg3,
1659 typename std_cxx11::tuple_element<3,ArgList>::type arg4,
1660 typename std_cxx11::tuple_element<4,ArgList>::type arg5,
1661 typename std_cxx11::tuple_element<5,ArgList>::type arg6,
1662 typename std_cxx11::tuple_element<6,ArgList>::type arg7,
1663 typename std_cxx11::tuple_element<7,ArgList>::type arg8)
1667 (std_cxx11::bind (
function,
1668 internal::maybe_make_ref<
typename std_cxx11::tuple_element<0,ArgList>::type>::act(arg1),
1669 internal::maybe_make_ref<
typename std_cxx11::tuple_element<1,ArgList>::type>::act(arg2),
1670 internal::maybe_make_ref<
typename std_cxx11::tuple_element<2,ArgList>::type>::act(arg3),
1671 internal::maybe_make_ref<
typename std_cxx11::tuple_element<3,ArgList>::type>::act(arg4),
1672 internal::maybe_make_ref<
typename std_cxx11::tuple_element<4,ArgList>::type>::act(arg5),
1673 internal::maybe_make_ref<
typename std_cxx11::tuple_element<5,ArgList>::type>::act(arg6),
1674 internal::maybe_make_ref<
typename std_cxx11::tuple_element<6,ArgList>::type>::act(arg7),
1675 internal::maybe_make_ref<
typename std_cxx11::tuple_element<7,ArgList>::type>::act(arg8)));
1679 std_cxx11::function<typename internal::fun_ptr<RT,ArgList>::type>
function;
1687 template <
typename RT,
typename ArgList>
1688 class fun_encapsulator<RT, ArgList, 9>
1691 fun_encapsulator (
typename internal::fun_ptr<RT,ArgList>::type *
function)
1692 : function (*function)
1695 fun_encapsulator (
const std_cxx11::function<
typename internal::fun_ptr<RT,ArgList>::type> &
function)
1696 : function (function)
1701 operator() (
typename std_cxx11::tuple_element<0,ArgList>::type arg1,
1702 typename std_cxx11::tuple_element<1,ArgList>::type arg2,
1703 typename std_cxx11::tuple_element<2,ArgList>::type arg3,
1704 typename std_cxx11::tuple_element<3,ArgList>::type arg4,
1705 typename std_cxx11::tuple_element<4,ArgList>::type arg5,
1706 typename std_cxx11::tuple_element<5,ArgList>::type arg6,
1707 typename std_cxx11::tuple_element<6,ArgList>::type arg7,
1708 typename std_cxx11::tuple_element<7,ArgList>::type arg8,
1709 typename std_cxx11::tuple_element<8,ArgList>::type arg9)
1713 (std_cxx11::bind (
function,
1714 internal::maybe_make_ref<
typename std_cxx11::tuple_element<0,ArgList>::type>::act(arg1),
1715 internal::maybe_make_ref<
typename std_cxx11::tuple_element<1,ArgList>::type>::act(arg2),
1716 internal::maybe_make_ref<
typename std_cxx11::tuple_element<2,ArgList>::type>::act(arg3),
1717 internal::maybe_make_ref<
typename std_cxx11::tuple_element<3,ArgList>::type>::act(arg4),
1718 internal::maybe_make_ref<
typename std_cxx11::tuple_element<4,ArgList>::type>::act(arg5),
1719 internal::maybe_make_ref<
typename std_cxx11::tuple_element<5,ArgList>::type>::act(arg6),
1720 internal::maybe_make_ref<
typename std_cxx11::tuple_element<6,ArgList>::type>::act(arg7),
1721 internal::maybe_make_ref<
typename std_cxx11::tuple_element<7,ArgList>::type>::act(arg8),
1722 internal::maybe_make_ref<
typename std_cxx11::tuple_element<8,ArgList>::type>::act(arg9)));
1726 std_cxx11::function<typename internal::fun_ptr<RT,ArgList>::type>
function;
1742 template <
typename RT>
1751 #ifdef DEAL_II_WITH_CXX11 1816 template <
typename FunctionObjectType>
1822 typedef decltype(function_object()) return_type;
1835 template <
typename RT>
1840 return new_thread (std_cxx11::function<RT ()> (fun_ptr));
1850 template <
typename RT,
typename C>
1854 typename identity<C>::type &c)
1858 (std_cxx11::bind(fun_ptr, std_cxx11::ref(c))));
1862 #ifndef DEAL_II_CONST_MEMBER_DEDUCTION_BUG 1869 template <
typename RT,
typename C>
1873 const typename identity<C>::type &c)
1877 (std_cxx11::bind(fun_ptr, std_cxx11::cref(c))));
1891 template <
typename RT,
typename Arg1>
1895 typename identity<Arg1>::type arg1)
1899 (std_cxx11::bind(fun_ptr,
1911 template <
typename RT,
typename C,
typename Arg1>
1915 typename identity<C>::type &c,
1916 typename identity<Arg1>::type arg1)
1920 (std_cxx11::bind(fun_ptr, std_cxx11::ref(c),
1924 #ifndef DEAL_II_CONST_MEMBER_DEDUCTION_BUG 1931 template <
typename RT,
typename C,
typename Arg1>
1935 typename identity<const C>::type &c,
1936 typename identity<Arg1>::type arg1)
1940 (std_cxx11::bind(fun_ptr, std_cxx11::cref(c),
1953 template <
typename RT,
typename Arg1,
typename Arg2>
1957 typename identity<Arg1>::type arg1,
1958 typename identity<Arg2>::type arg2)
1962 (std_cxx11::bind(fun_ptr,
1975 template <
typename RT,
typename C,
typename Arg1,
typename Arg2>
1979 typename identity<C>::type &c,
1980 typename identity<Arg1>::type arg1,
1981 typename identity<Arg2>::type arg2)
1985 (std_cxx11::bind(fun_ptr, std_cxx11::ref(c),
1990 #ifndef DEAL_II_CONST_MEMBER_DEDUCTION_BUG 1997 template <
typename RT,
typename C,
typename Arg1,
typename Arg2>
2001 typename identity<const C>::type &c,
2002 typename identity<Arg1>::type arg1,
2003 typename identity<Arg2>::type arg2)
2007 (std_cxx11::bind(fun_ptr, std_cxx11::cref(c),
2021 template <
typename RT,
2022 typename Arg1,
typename Arg2,
typename Arg3>
2026 typename identity<Arg1>::type arg1,
2027 typename identity<Arg2>::type arg2,
2028 typename identity<Arg3>::type arg3)
2032 (std_cxx11::bind(fun_ptr,
2046 template <
typename RT,
typename C,
2047 typename Arg1,
typename Arg2,
typename Arg3>
2051 typename identity<C>::type &c,
2052 typename identity<Arg1>::type arg1,
2053 typename identity<Arg2>::type arg2,
2054 typename identity<Arg3>::type arg3)
2058 (std_cxx11::bind(fun_ptr, std_cxx11::ref(c),
2064 #ifndef DEAL_II_CONST_MEMBER_DEDUCTION_BUG 2071 template <
typename RT,
typename C,
2072 typename Arg1,
typename Arg2,
typename Arg3>
2076 typename identity<const C>::type &c,
2077 typename identity<Arg1>::type arg1,
2078 typename identity<Arg2>::type arg2,
2079 typename identity<Arg3>::type arg3)
2083 (std_cxx11::bind(fun_ptr, std_cxx11::cref(c),
2099 template <
typename RT,
2100 typename Arg1,
typename Arg2,
typename Arg3,
typename Arg4>
2104 typename identity<Arg1>::type arg1,
2105 typename identity<Arg2>::type arg2,
2106 typename identity<Arg3>::type arg3,
2107 typename identity<Arg4>::type arg4)
2111 (std_cxx11::bind(fun_ptr,
2126 template <
typename RT,
typename C,
2127 typename Arg1,
typename Arg2,
typename Arg3,
typename Arg4>
2131 typename identity<C>::type &c,
2132 typename identity<Arg1>::type arg1,
2133 typename identity<Arg2>::type arg2,
2134 typename identity<Arg3>::type arg3,
2135 typename identity<Arg4>::type arg4)
2139 (std_cxx11::bind(fun_ptr, std_cxx11::ref(c),
2146 #ifndef DEAL_II_CONST_MEMBER_DEDUCTION_BUG 2153 template <
typename RT,
typename C,
2154 typename Arg1,
typename Arg2,
typename Arg3,
typename Arg4>
2158 typename identity<const C>::type &c,
2159 typename identity<Arg1>::type arg1,
2160 typename identity<Arg2>::type arg2,
2161 typename identity<Arg3>::type arg3,
2162 typename identity<Arg4>::type arg4)
2166 (std_cxx11::bind(fun_ptr, std_cxx11::cref(c),
2182 template <
typename RT,
2183 typename Arg1,
typename Arg2,
typename Arg3,
2184 typename Arg4,
typename Arg5>
2188 typename identity<Arg1>::type arg1,
2189 typename identity<Arg2>::type arg2,
2190 typename identity<Arg3>::type arg3,
2191 typename identity<Arg4>::type arg4,
2192 typename identity<Arg5>::type arg5)
2196 (std_cxx11::bind(fun_ptr,
2212 template <
typename RT,
typename C,
2213 typename Arg1,
typename Arg2,
typename Arg3,
2214 typename Arg4,
typename Arg5>
2218 typename identity<C>::type &c,
2219 typename identity<Arg1>::type arg1,
2220 typename identity<Arg2>::type arg2,
2221 typename identity<Arg3>::type arg3,
2222 typename identity<Arg4>::type arg4,
2223 typename identity<Arg5>::type arg5)
2227 (std_cxx11::bind(fun_ptr, std_cxx11::ref(c),
2235 #ifndef DEAL_II_CONST_MEMBER_DEDUCTION_BUG 2242 template <
typename RT,
typename C,
2243 typename Arg1,
typename Arg2,
typename Arg3,
2244 typename Arg4,
typename Arg5>
2248 typename identity<const C>::type &c,
2249 typename identity<Arg1>::type arg1,
2250 typename identity<Arg2>::type arg2,
2251 typename identity<Arg3>::type arg3,
2252 typename identity<Arg4>::type arg4,
2253 typename identity<Arg5>::type arg5)
2257 (std_cxx11::bind(fun_ptr, std_cxx11::cref(c),
2274 template <
typename RT,
2275 typename Arg1,
typename Arg2,
typename Arg3,
2276 typename Arg4,
typename Arg5,
typename Arg6>
2280 typename identity<Arg1>::type arg1,
2281 typename identity<Arg2>::type arg2,
2282 typename identity<Arg3>::type arg3,
2283 typename identity<Arg4>::type arg4,
2284 typename identity<Arg5>::type arg5,
2285 typename identity<Arg6>::type arg6)
2289 (std_cxx11::bind(fun_ptr,
2306 template <
typename RT,
typename C,
2307 typename Arg1,
typename Arg2,
typename Arg3,
2308 typename Arg4,
typename Arg5,
typename Arg6>
2312 typename identity<C>::type &c,
2313 typename identity<Arg1>::type arg1,
2314 typename identity<Arg2>::type arg2,
2315 typename identity<Arg3>::type arg3,
2316 typename identity<Arg4>::type arg4,
2317 typename identity<Arg5>::type arg5,
2318 typename identity<Arg6>::type arg6)
2322 (std_cxx11::bind(fun_ptr, std_cxx11::ref(c),
2331 #ifndef DEAL_II_CONST_MEMBER_DEDUCTION_BUG 2338 template <
typename RT,
typename C,
2339 typename Arg1,
typename Arg2,
typename Arg3,
2340 typename Arg4,
typename Arg5,
typename Arg6>
2343 new_thread (RT (C::*fun_ptr)(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6)
const,
2344 typename identity<const C>::type &c,
2345 typename identity<Arg1>::type arg1,
2346 typename identity<Arg2>::type arg2,
2347 typename identity<Arg3>::type arg3,
2348 typename identity<Arg4>::type arg4,
2349 typename identity<Arg5>::type arg5,
2350 typename identity<Arg6>::type arg6)
2354 (std_cxx11::bind(fun_ptr, std_cxx11::cref(c),
2372 template <
typename RT,
2373 typename Arg1,
typename Arg2,
typename Arg3,
2374 typename Arg4,
typename Arg5,
typename Arg6,
2379 typename identity<Arg1>::type arg1,
2380 typename identity<Arg2>::type arg2,
2381 typename identity<Arg3>::type arg3,
2382 typename identity<Arg4>::type arg4,
2383 typename identity<Arg5>::type arg5,
2384 typename identity<Arg6>::type arg6,
2385 typename identity<Arg7>::type arg7)
2389 (std_cxx11::bind(fun_ptr,
2407 template <
typename RT,
typename C,
2408 typename Arg1,
typename Arg2,
typename Arg3,
2409 typename Arg4,
typename Arg5,
typename Arg6,
2413 new_thread (RT (C::*fun_ptr)(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7),
2414 typename identity<C>::type &c,
2415 typename identity<Arg1>::type arg1,
2416 typename identity<Arg2>::type arg2,
2417 typename identity<Arg3>::type arg3,
2418 typename identity<Arg4>::type arg4,
2419 typename identity<Arg5>::type arg5,
2420 typename identity<Arg6>::type arg6,
2421 typename identity<Arg7>::type arg7)
2425 (std_cxx11::bind(fun_ptr, std_cxx11::ref(c),
2435 #ifndef DEAL_II_CONST_MEMBER_DEDUCTION_BUG 2442 template <
typename RT,
typename C,
2443 typename Arg1,
typename Arg2,
typename Arg3,
2444 typename Arg4,
typename Arg5,
typename Arg6,
2448 new_thread (RT (C::*fun_ptr)(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7)
const,
2449 typename identity<const C>::type &c,
2450 typename identity<Arg1>::type arg1,
2451 typename identity<Arg2>::type arg2,
2452 typename identity<Arg3>::type arg3,
2453 typename identity<Arg4>::type arg4,
2454 typename identity<Arg5>::type arg5,
2455 typename identity<Arg6>::type arg6,
2456 typename identity<Arg7>::type arg7)
2460 (std_cxx11::bind(fun_ptr, std_cxx11::cref(c),
2479 template <
typename RT,
2480 typename Arg1,
typename Arg2,
typename Arg3,
2481 typename Arg4,
typename Arg5,
typename Arg6,
2482 typename Arg7,
typename Arg8>
2487 typename identity<Arg1>::type arg1,
2488 typename identity<Arg2>::type arg2,
2489 typename identity<Arg3>::type arg3,
2490 typename identity<Arg4>::type arg4,
2491 typename identity<Arg5>::type arg5,
2492 typename identity<Arg6>::type arg6,
2493 typename identity<Arg7>::type arg7,
2494 typename identity<Arg8>::type arg8)
2498 (std_cxx11::bind(fun_ptr,
2517 template <
typename RT,
typename C,
2518 typename Arg1,
typename Arg2,
typename Arg3,
2519 typename Arg4,
typename Arg5,
typename Arg6,
2520 typename Arg7,
typename Arg8>
2525 typename identity<C>::type &c,
2526 typename identity<Arg1>::type arg1,
2527 typename identity<Arg2>::type arg2,
2528 typename identity<Arg3>::type arg3,
2529 typename identity<Arg4>::type arg4,
2530 typename identity<Arg5>::type arg5,
2531 typename identity<Arg6>::type arg6,
2532 typename identity<Arg7>::type arg7,
2533 typename identity<Arg8>::type arg8)
2537 (std_cxx11::bind(fun_ptr, std_cxx11::ref(c),
2548 #ifndef DEAL_II_CONST_MEMBER_DEDUCTION_BUG 2555 template <
typename RT,
typename C,
2556 typename Arg1,
typename Arg2,
typename Arg3,
2557 typename Arg4,
typename Arg5,
typename Arg6,
2558 typename Arg7,
typename Arg8>
2562 Arg6,Arg7,Arg8)
const,
2563 typename identity<const C>::type &c,
2564 typename identity<Arg1>::type arg1,
2565 typename identity<Arg2>::type arg2,
2566 typename identity<Arg3>::type arg3,
2567 typename identity<Arg4>::type arg4,
2568 typename identity<Arg5>::type arg5,
2569 typename identity<Arg6>::type arg6,
2570 typename identity<Arg7>::type arg7,
2571 typename identity<Arg8>::type arg8)
2575 (std_cxx11::bind(fun_ptr, std_cxx11::cref(c),
2595 template <
typename RT,
2596 typename Arg1,
typename Arg2,
typename Arg3,
2597 typename Arg4,
typename Arg5,
typename Arg6,
2598 typename Arg7,
typename Arg8,
typename Arg9>
2602 Arg6,Arg7,Arg8,Arg9),
2603 typename identity<Arg1>::type arg1,
2604 typename identity<Arg2>::type arg2,
2605 typename identity<Arg3>::type arg3,
2606 typename identity<Arg4>::type arg4,
2607 typename identity<Arg5>::type arg5,
2608 typename identity<Arg6>::type arg6,
2609 typename identity<Arg7>::type arg7,
2610 typename identity<Arg8>::type arg8,
2611 typename identity<Arg9>::type arg9)
2615 (std_cxx11::bind(fun_ptr,
2635 template <
typename RT,
typename C,
2636 typename Arg1,
typename Arg2,
typename Arg3,
2637 typename Arg4,
typename Arg5,
typename Arg6,
2638 typename Arg7,
typename Arg8,
typename Arg9>
2642 Arg6,Arg7,Arg8,Arg9),
2643 typename identity<C>::type &c,
2644 typename identity<Arg1>::type arg1,
2645 typename identity<Arg2>::type arg2,
2646 typename identity<Arg3>::type arg3,
2647 typename identity<Arg4>::type arg4,
2648 typename identity<Arg5>::type arg5,
2649 typename identity<Arg6>::type arg6,
2650 typename identity<Arg7>::type arg7,
2651 typename identity<Arg8>::type arg8,
2652 typename identity<Arg9>::type arg9)
2656 (std_cxx11::bind(fun_ptr, std_cxx11::ref(c),
2668 #ifndef DEAL_II_CONST_MEMBER_DEDUCTION_BUG 2675 template <
typename RT,
typename C,
2676 typename Arg1,
typename Arg2,
typename Arg3,
2677 typename Arg4,
typename Arg5,
typename Arg6,
2678 typename Arg7,
typename Arg8,
typename Arg9>
2682 Arg6,Arg7,Arg8,Arg9)
const,
2683 typename identity<const C>::type &c,
2684 typename identity<Arg1>::type arg1,
2685 typename identity<Arg2>::type arg2,
2686 typename identity<Arg3>::type arg3,
2687 typename identity<Arg4>::type arg4,
2688 typename identity<Arg5>::type arg5,
2689 typename identity<Arg6>::type arg6,
2690 typename identity<Arg7>::type arg7,
2691 typename identity<Arg8>::type arg8,
2692 typename identity<Arg9>::type arg9)
2696 (std_cxx11::bind(fun_ptr, std_cxx11::cref(c),
2719 template <
typename RT =
void>
2740 for (
typename std::list<
Thread<RT> >::const_iterator
2758 #ifdef DEAL_II_WITH_THREADS 2760 template <
typename>
struct TaskDescriptor;
2765 template <
typename RT>
2773 virtual tbb::task *execute ()
2781 catch (
const std::exception &exc)
2783 internal::handle_std_exception (exc);
2787 internal::handle_unknown_exception ();
2819 template <
typename RT>
2820 struct TaskDescriptor
2826 std_cxx11::function<RT ()>
function;
2841 return_value<RT> ret_val;
2853 TaskDescriptor (
const std_cxx11::function<RT ()> &
function);
2866 TaskDescriptor (
const TaskDescriptor &);
2878 operator = (
const TaskDescriptor &);
2897 friend class ::Threads::Task<RT>;
2902 template <
typename RT>
2904 TaskDescriptor<RT>::TaskDescriptor (
const std_cxx11::function<RT ()> &
function)
2906 function (function),
2908 task_is_done (false)
2912 template <
typename RT>
2915 TaskDescriptor<RT>::queue_task ()
2919 task =
new (tbb::task::allocate_root()) tbb::empty_task;
2920 task->set_ref_count (2);
2922 tbb::task *worker =
new (task->allocate_child()) TaskEntryPoint<RT>(*
this);
2929 #if TBB_VERSION_MAJOR >= 4 2930 tbb::task::spawn (*worker);
2932 task->spawn (*worker);
2938 template <
typename RT>
2939 TaskDescriptor<RT>::TaskDescriptor ()
2941 task_is_done (false)
2948 template <
typename RT>
2949 TaskDescriptor<RT>::TaskDescriptor (
const TaskDescriptor &)
2951 task_is_done (false)
2960 template <
typename RT>
2962 TaskDescriptor<RT>::~TaskDescriptor ()
2979 task->destroy (*task);
2983 template <
typename RT>
2984 TaskDescriptor<RT> &
2985 TaskDescriptor<RT>::operator = (
const TaskDescriptor &)
2994 template <
typename RT>
2997 TaskDescriptor<RT>::join ()
3008 if (task_is_done ==
true)
3012 task_is_done =
true;
3013 task->wait_for_all();
3018 #else // no threading enabled 3024 template <
typename RT>
3025 struct TaskDescriptor
3030 return_value<RT> ret_val;
3036 TaskDescriptor (
const std_cxx11::function<RT ()> &
function)
3038 call (
function, ret_val);
3045 static void join () {}
3051 static void queue_task () {}
3070 template <
typename RT =
void>
3081 Task (
const std_cxx11::function<RT ()> &function_object)
3085 task_descriptor.reset (
new internal::TaskDescriptor<RT>(function_object));
3144 std_cxx11::shared_ptr<internal::TaskDescriptor<RT> >());
3185 "The current object is not associated with a task that " 3186 "can be joined. It may have been detached, or you " 3187 "may have already joined it in the past.");
3208 template <
typename RT>
3217 #ifdef DEAL_II_WITH_CXX11 3282 template <
typename FunctionObjectType>
3288 typedef decltype(function_object()) return_type;
3300 template <
typename RT>
3305 return new_task (std_cxx11::function<RT ()>(fun_ptr));
3315 template <
typename RT,
typename C>
3319 typename identity<C>::type &c)
3322 new_task (std_cxx11::function<RT ()>
3323 (std_cxx11::bind(fun_ptr, std_cxx11::ref(c))));
3326 #ifndef DEAL_II_CONST_MEMBER_DEDUCTION_BUG 3333 template <
typename RT,
typename C>
3337 const typename identity<C>::type &c)
3340 new_task (std_cxx11::function<RT ()>
3341 (std_cxx11::bind(fun_ptr, std_cxx11::cref(c))));
3355 template <
typename RT,
typename Arg1>
3359 typename identity<Arg1>::type arg1)
3362 new_task (std_cxx11::function<RT ()>
3363 (std_cxx11::bind(fun_ptr,
3375 template <
typename RT,
typename C,
typename Arg1>
3379 typename identity<C>::type &c,
3380 typename identity<Arg1>::type arg1)
3383 new_task (std_cxx11::function<RT ()>
3384 (std_cxx11::bind(fun_ptr, std_cxx11::ref(c),
3388 #ifndef DEAL_II_CONST_MEMBER_DEDUCTION_BUG 3395 template <
typename RT,
typename C,
typename Arg1>
3399 typename identity<const C>::type &c,
3400 typename identity<Arg1>::type arg1)
3403 new_task (std_cxx11::function<RT ()>
3404 (std_cxx11::bind(fun_ptr, std_cxx11::cref(c),
3417 template <
typename RT,
typename Arg1,
typename Arg2>
3421 typename identity<Arg1>::type arg1,
3422 typename identity<Arg2>::type arg2)
3425 new_task (std_cxx11::function<RT ()>
3426 (std_cxx11::bind(fun_ptr,
3439 template <
typename RT,
typename C,
typename Arg1,
typename Arg2>
3443 typename identity<C>::type &c,
3444 typename identity<Arg1>::type arg1,
3445 typename identity<Arg2>::type arg2)
3448 new_task (std_cxx11::function<RT ()>
3449 (std_cxx11::bind(fun_ptr, std_cxx11::ref(c),
3454 #ifndef DEAL_II_CONST_MEMBER_DEDUCTION_BUG 3461 template <
typename RT,
typename C,
typename Arg1,
typename Arg2>
3465 typename identity<const C>::type &c,
3466 typename identity<Arg1>::type arg1,
3467 typename identity<Arg2>::type arg2)
3470 new_task (std_cxx11::function<RT ()>
3471 (std_cxx11::bind(fun_ptr, std_cxx11::cref(c),
3485 template <
typename RT,
3486 typename Arg1,
typename Arg2,
typename Arg3>
3490 typename identity<Arg1>::type arg1,
3491 typename identity<Arg2>::type arg2,
3492 typename identity<Arg3>::type arg3)
3495 new_task (std_cxx11::function<RT ()>
3496 (std_cxx11::bind(fun_ptr,
3510 template <
typename RT,
typename C,
3511 typename Arg1,
typename Arg2,
typename Arg3>
3515 typename identity<C>::type &c,
3516 typename identity<Arg1>::type arg1,
3517 typename identity<Arg2>::type arg2,
3518 typename identity<Arg3>::type arg3)
3521 new_task (std_cxx11::function<RT ()>
3522 (std_cxx11::bind(fun_ptr, std_cxx11::ref(c),
3528 #ifndef DEAL_II_CONST_MEMBER_DEDUCTION_BUG 3535 template <
typename RT,
typename C,
3536 typename Arg1,
typename Arg2,
typename Arg3>
3540 typename identity<const C>::type &c,
3541 typename identity<Arg1>::type arg1,
3542 typename identity<Arg2>::type arg2,
3543 typename identity<Arg3>::type arg3)
3546 new_task (std_cxx11::function<RT ()>
3547 (std_cxx11::bind(fun_ptr, std_cxx11::cref(c),
3563 template <
typename RT,
3564 typename Arg1,
typename Arg2,
typename Arg3,
typename Arg4>
3568 typename identity<Arg1>::type arg1,
3569 typename identity<Arg2>::type arg2,
3570 typename identity<Arg3>::type arg3,
3571 typename identity<Arg4>::type arg4)
3574 new_task (std_cxx11::function<RT ()>
3575 (std_cxx11::bind(fun_ptr,
3590 template <
typename RT,
typename C,
3591 typename Arg1,
typename Arg2,
typename Arg3,
typename Arg4>
3595 typename identity<C>::type &c,
3596 typename identity<Arg1>::type arg1,
3597 typename identity<Arg2>::type arg2,
3598 typename identity<Arg3>::type arg3,
3599 typename identity<Arg4>::type arg4)
3602 new_task (std_cxx11::function<RT ()>
3603 (std_cxx11::bind(fun_ptr, std_cxx11::ref(c),
3610 #ifndef DEAL_II_CONST_MEMBER_DEDUCTION_BUG 3617 template <
typename RT,
typename C,
3618 typename Arg1,
typename Arg2,
typename Arg3,
typename Arg4>
3622 typename identity<const C>::type &c,
3623 typename identity<Arg1>::type arg1,
3624 typename identity<Arg2>::type arg2,
3625 typename identity<Arg3>::type arg3,
3626 typename identity<Arg4>::type arg4)
3629 new_task (std_cxx11::function<RT ()>
3630 (std_cxx11::bind(fun_ptr, std_cxx11::cref(c),
3646 template <
typename RT,
3647 typename Arg1,
typename Arg2,
typename Arg3,
3648 typename Arg4,
typename Arg5>
3652 typename identity<Arg1>::type arg1,
3653 typename identity<Arg2>::type arg2,
3654 typename identity<Arg3>::type arg3,
3655 typename identity<Arg4>::type arg4,
3656 typename identity<Arg5>::type arg5)
3659 new_task (std_cxx11::function<RT ()>
3660 (std_cxx11::bind(fun_ptr,
3676 template <
typename RT,
typename C,
3677 typename Arg1,
typename Arg2,
typename Arg3,
3678 typename Arg4,
typename Arg5>
3682 typename identity<C>::type &c,
3683 typename identity<Arg1>::type arg1,
3684 typename identity<Arg2>::type arg2,
3685 typename identity<Arg3>::type arg3,
3686 typename identity<Arg4>::type arg4,
3687 typename identity<Arg5>::type arg5)
3690 new_task (std_cxx11::function<RT ()>
3691 (std_cxx11::bind(fun_ptr, std_cxx11::ref(c),
3699 #ifndef DEAL_II_CONST_MEMBER_DEDUCTION_BUG 3706 template <
typename RT,
typename C,
3707 typename Arg1,
typename Arg2,
typename Arg3,
3708 typename Arg4,
typename Arg5>
3711 new_task (RT (C::*fun_ptr)(Arg1,Arg2,Arg3,Arg4,Arg5)
const,
3712 typename identity<const C>::type &c,
3713 typename identity<Arg1>::type arg1,
3714 typename identity<Arg2>::type arg2,
3715 typename identity<Arg3>::type arg3,
3716 typename identity<Arg4>::type arg4,
3717 typename identity<Arg5>::type arg5)
3720 new_task (std_cxx11::function<RT ()>
3721 (std_cxx11::bind(fun_ptr, std_cxx11::cref(c),
3738 template <
typename RT,
3739 typename Arg1,
typename Arg2,
typename Arg3,
3740 typename Arg4,
typename Arg5,
typename Arg6>
3743 new_task (RT (*fun_ptr)(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6),
3744 typename identity<Arg1>::type arg1,
3745 typename identity<Arg2>::type arg2,
3746 typename identity<Arg3>::type arg3,
3747 typename identity<Arg4>::type arg4,
3748 typename identity<Arg5>::type arg5,
3749 typename identity<Arg6>::type arg6)
3752 new_task (std_cxx11::function<RT ()>
3753 (std_cxx11::bind(fun_ptr,
3770 template <
typename RT,
typename C,
3771 typename Arg1,
typename Arg2,
typename Arg3,
3772 typename Arg4,
typename Arg5,
typename Arg6>
3775 new_task (RT (C::*fun_ptr)(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6),
3776 typename identity<C>::type &c,
3777 typename identity<Arg1>::type arg1,
3778 typename identity<Arg2>::type arg2,
3779 typename identity<Arg3>::type arg3,
3780 typename identity<Arg4>::type arg4,
3781 typename identity<Arg5>::type arg5,
3782 typename identity<Arg6>::type arg6)
3785 new_task (std_cxx11::function<RT ()>
3786 (std_cxx11::bind(fun_ptr, std_cxx11::ref(c),
3795 #ifndef DEAL_II_CONST_MEMBER_DEDUCTION_BUG 3802 template <
typename RT,
typename C,
3803 typename Arg1,
typename Arg2,
typename Arg3,
3804 typename Arg4,
typename Arg5,
typename Arg6>
3807 new_task (RT (C::*fun_ptr)(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6)
const,
3808 typename identity<const C>::type &c,
3809 typename identity<Arg1>::type arg1,
3810 typename identity<Arg2>::type arg2,
3811 typename identity<Arg3>::type arg3,
3812 typename identity<Arg4>::type arg4,
3813 typename identity<Arg5>::type arg5,
3814 typename identity<Arg6>::type arg6)
3817 new_task (std_cxx11::function<RT ()>
3818 (std_cxx11::bind(fun_ptr, std_cxx11::cref(c),
3836 template <
typename RT,
3837 typename Arg1,
typename Arg2,
typename Arg3,
3838 typename Arg4,
typename Arg5,
typename Arg6,
3842 new_task (RT (*fun_ptr)(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7),
3843 typename identity<Arg1>::type arg1,
3844 typename identity<Arg2>::type arg2,
3845 typename identity<Arg3>::type arg3,
3846 typename identity<Arg4>::type arg4,
3847 typename identity<Arg5>::type arg5,
3848 typename identity<Arg6>::type arg6,
3849 typename identity<Arg7>::type arg7)
3852 new_task (std_cxx11::function<RT ()>
3853 (std_cxx11::bind(fun_ptr,
3871 template <
typename RT,
typename C,
3872 typename Arg1,
typename Arg2,
typename Arg3,
3873 typename Arg4,
typename Arg5,
typename Arg6,
3877 new_task (RT (C::*fun_ptr)(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7),
3878 typename identity<C>::type &c,
3879 typename identity<Arg1>::type arg1,
3880 typename identity<Arg2>::type arg2,
3881 typename identity<Arg3>::type arg3,
3882 typename identity<Arg4>::type arg4,
3883 typename identity<Arg5>::type arg5,
3884 typename identity<Arg6>::type arg6,
3885 typename identity<Arg7>::type arg7)
3888 new_task (std_cxx11::function<RT ()>
3889 (std_cxx11::bind(fun_ptr, std_cxx11::ref(c),
3899 #ifndef DEAL_II_CONST_MEMBER_DEDUCTION_BUG 3906 template <
typename RT,
typename C,
3907 typename Arg1,
typename Arg2,
typename Arg3,
3908 typename Arg4,
typename Arg5,
typename Arg6,
3912 new_task (RT (C::*fun_ptr)(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7)
const,
3913 typename identity<const C>::type &c,
3914 typename identity<Arg1>::type arg1,
3915 typename identity<Arg2>::type arg2,
3916 typename identity<Arg3>::type arg3,
3917 typename identity<Arg4>::type arg4,
3918 typename identity<Arg5>::type arg5,
3919 typename identity<Arg6>::type arg6,
3920 typename identity<Arg7>::type arg7)
3923 new_task (std_cxx11::function<RT ()>
3924 (std_cxx11::bind(fun_ptr, std_cxx11::cref(c),
3943 template <
typename RT,
3944 typename Arg1,
typename Arg2,
typename Arg3,
3945 typename Arg4,
typename Arg5,
typename Arg6,
3946 typename Arg7,
typename Arg8>
3951 typename identity<Arg1>::type arg1,
3952 typename identity<Arg2>::type arg2,
3953 typename identity<Arg3>::type arg3,
3954 typename identity<Arg4>::type arg4,
3955 typename identity<Arg5>::type arg5,
3956 typename identity<Arg6>::type arg6,
3957 typename identity<Arg7>::type arg7,
3958 typename identity<Arg8>::type arg8)
3961 new_task (std_cxx11::function<RT ()>
3962 (std_cxx11::bind(fun_ptr,
3981 template <
typename RT,
typename C,
3982 typename Arg1,
typename Arg2,
typename Arg3,
3983 typename Arg4,
typename Arg5,
typename Arg6,
3984 typename Arg7,
typename Arg8>
3989 typename identity<C>::type &c,
3990 typename identity<Arg1>::type arg1,
3991 typename identity<Arg2>::type arg2,
3992 typename identity<Arg3>::type arg3,
3993 typename identity<Arg4>::type arg4,
3994 typename identity<Arg5>::type arg5,
3995 typename identity<Arg6>::type arg6,
3996 typename identity<Arg7>::type arg7,
3997 typename identity<Arg8>::type arg8)
4000 new_task (std_cxx11::function<RT ()>
4001 (std_cxx11::bind(fun_ptr, std_cxx11::ref(c),
4012 #ifndef DEAL_II_CONST_MEMBER_DEDUCTION_BUG 4019 template <
typename RT,
typename C,
4020 typename Arg1,
typename Arg2,
typename Arg3,
4021 typename Arg4,
typename Arg5,
typename Arg6,
4022 typename Arg7,
typename Arg8>
4026 Arg6,Arg7,Arg8)
const,
4027 typename identity<const C>::type &c,
4028 typename identity<Arg1>::type arg1,
4029 typename identity<Arg2>::type arg2,
4030 typename identity<Arg3>::type arg3,
4031 typename identity<Arg4>::type arg4,
4032 typename identity<Arg5>::type arg5,
4033 typename identity<Arg6>::type arg6,
4034 typename identity<Arg7>::type arg7,
4035 typename identity<Arg8>::type arg8)
4038 new_task (std_cxx11::function<RT ()>
4039 (std_cxx11::bind(fun_ptr, std_cxx11::cref(c),
4059 template <
typename RT,
4060 typename Arg1,
typename Arg2,
typename Arg3,
4061 typename Arg4,
typename Arg5,
typename Arg6,
4062 typename Arg7,
typename Arg8,
typename Arg9>
4066 Arg6,Arg7,Arg8,Arg9),
4067 typename identity<Arg1>::type arg1,
4068 typename identity<Arg2>::type arg2,
4069 typename identity<Arg3>::type arg3,
4070 typename identity<Arg4>::type arg4,
4071 typename identity<Arg5>::type arg5,
4072 typename identity<Arg6>::type arg6,
4073 typename identity<Arg7>::type arg7,
4074 typename identity<Arg8>::type arg8,
4075 typename identity<Arg9>::type arg9)
4078 new_task (std_cxx11::function<RT ()>
4079 (std_cxx11::bind(fun_ptr,
4099 template <
typename RT,
typename C,
4100 typename Arg1,
typename Arg2,
typename Arg3,
4101 typename Arg4,
typename Arg5,
typename Arg6,
4102 typename Arg7,
typename Arg8,
typename Arg9>
4106 Arg6,Arg7,Arg8,Arg9),
4107 typename identity<C>::type &c,
4108 typename identity<Arg1>::type arg1,
4109 typename identity<Arg2>::type arg2,
4110 typename identity<Arg3>::type arg3,
4111 typename identity<Arg4>::type arg4,
4112 typename identity<Arg5>::type arg5,
4113 typename identity<Arg6>::type arg6,
4114 typename identity<Arg7>::type arg7,
4115 typename identity<Arg8>::type arg8,
4116 typename identity<Arg9>::type arg9)
4119 new_task (std_cxx11::function<RT ()>
4120 (std_cxx11::bind(fun_ptr, std_cxx11::ref(c),
4132 #ifndef DEAL_II_CONST_MEMBER_DEDUCTION_BUG 4139 template <
typename RT,
typename C,
4140 typename Arg1,
typename Arg2,
typename Arg3,
4141 typename Arg4,
typename Arg5,
typename Arg6,
4142 typename Arg7,
typename Arg8,
typename Arg9>
4146 Arg6,Arg7,Arg8,Arg9)
const,
4147 typename identity<const C>::type &c,
4148 typename identity<Arg1>::type arg1,
4149 typename identity<Arg2>::type arg2,
4150 typename identity<Arg3>::type arg3,
4151 typename identity<Arg4>::type arg4,
4152 typename identity<Arg5>::type arg5,
4153 typename identity<Arg6>::type arg6,
4154 typename identity<Arg7>::type arg7,
4155 typename identity<Arg8>::type arg8,
4156 typename identity<Arg9>::type arg9)
4159 new_task (std_cxx11::function<RT ()>
4160 (std_cxx11::bind(fun_ptr, std_cxx11::cref(c),
4189 template <
typename RT =
void>
4198 tasks.push_back (t);
4210 for (
typename std::list<
Task<RT> >::const_iterator
4230 DEAL_II_NAMESPACE_CLOSE
#define AssertNothrow(cond, exc)
std_cxx11::condition_variable condition_variable
Task(const std_cxx11::function< RT()> &function_object)
std::vector< std::pair< ForwardIterator, ForwardIterator > > split_range(const ForwardIterator &begin, const ForwardIterator &end, const unsigned int n_intervals)
unsigned int this_thread_id()
void start(const std_cxx11::function< RT()> &function)
Thread(const Thread< RT > &t)
TaskDescriptor< RT > & task_descriptor
std::list< Task< RT > > tasks
Thread(const std_cxx11::function< RT()> &function)
static void thread_entry_point(const std_cxx11::function< RT()> function, std_cxx11::shared_ptr< return_value< RT > > ret_val)
ScopedLock(DummyThreadMutex &)
#define AssertThrow(cond, exc)
PosixThreadBarrier(const unsigned int count, const char *name=0, void *arg=0)
bool operator==(const Task &t) const
std::vector< std::pair< unsigned int, unsigned int > > split_interval(const unsigned int begin, const unsigned int end, const unsigned int n_intervals)
Mutex & operator=(const Mutex &)
DummyBarrier(const unsigned int count, const char *name=0, void *arg=0)
static ::ExceptionBase & ExcNoTask()
#define DeclException1(Exception1, type1, outsequence)
Thread< RT > new_thread(const std_cxx11::function< RT()> &function)
#define Assert(cond, exc)
#define DeclExceptionMsg(Exception, defaulttext)
unsigned int n_existing_threads()
void wait(DummyThreadMutex &) const
std_cxx11::shared_ptr< internal::ThreadDescriptor< RT > > thread_descriptor
bool operator==(const Thread &t) const
TaskGroup & operator+=(const Task< RT > &t)
ThreadGroup & operator+=(const Thread< RT > &t)
std_cxx11::shared_ptr< return_value< RT > > ret_val
PosixThreadBarrier Barrier
Task(const Task< RT > &t)
Mutex thread_is_active_mutex
pthread_barrier_t barrier
std_cxx11::shared_ptr< internal::TaskDescriptor< RT > > task_descriptor
Task< RT > new_task(const std_cxx11::function< RT()> &function)
std::list< Thread< RT > > threads
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcBarrierSizeNotUseful(int arg1)