323 #ifdef CGU_USE_SCHED_YIELD
331 #include <functional>
376 std::list<Callback::SafeFunctor> disconnect_list;
507 template <
class FreeArg>
510 #ifndef DOXYGEN_PARSING
515 Callback::FunctorArg<FreeArg> f1;
519 f1(f1_), f2(f2_), blocked(false) {}
523 std::list<ListItem> emission_list;
529 void tracking_disconnect(Callback::FunctorArg<FreeArg>);
691 template <
class FreeArg>
694 struct DisconnectReleaserItem {
695 static void exec(
const ListItem& l) {(l.f2)();}
697 std::for_each(emission_list.begin(), emission_list.end(),
701 template <
class FreeArg>
730 std::list<ListItem> local_list = emission_list;
734 typename std::list<ListItem>::const_iterator iter;
735 for (iter = local_list.begin(); iter != local_list.end(); ++iter) {
736 if (!iter->blocked) iter->f1(arg);
740 template <
class FreeArg>
742 if (emission_list.empty())
return false;
747 template <
class FreeArg>
753 template <
class FreeArg>
766 emission_list.push_back(ListItem(f1, f2));
775 template <
class FreeArg>
787 typename std::list<ListItem>::iterator iter = emission_list.begin();
789 iter = std::find_if(iter, emission_list.end(),
790 std::bind2nd(std::ptr_fun(Pred::pred), arg));
791 if (iter != emission_list.end()) {
796 iter = emission_list.erase(iter);
805 template <
class FreeArg>
815 typename std::list<ListItem>::iterator iter = emission_list.begin();
817 iter = std::find_if(iter, emission_list.end(),
818 std::bind2nd(std::ptr_fun(Pred::pred), arg));
819 if (iter != emission_list.end()) {
821 iter = emission_list.erase(iter);
827 template <
class FreeArg>
839 typename std::list<ListItem>::iterator iter = emission_list.begin();
841 iter = std::find_if(iter, emission_list.end(),
842 std::bind2nd(std::ptr_fun(Pred::pred), arg));
843 if (iter != emission_list.end()) {
844 iter->blocked =
true;
851 template <
class FreeArg>
863 typename std::list<ListItem>::iterator iter = emission_list.begin();
865 iter = std::find_if(iter, emission_list.end(),
866 std::bind2nd(std::ptr_fun(Pred::pred), arg));
867 if (iter != emission_list.end()) {
868 iter->blocked =
false;
932 template <
class FreeArg>
935 #ifndef DOXYGEN_PARSING
944 f1(f1_), f2(f2_), blocked(false) {}
948 std::list<ListItem> emission_list;
949 mutable Thread::Mutex mutex;
955 void tracking_disconnect(Callback::SafeFunctorArg<FreeArg>);
1141 template <
class FreeArg>
1148 while (!emission_list.empty()) {
1149 typename std::list<ListItem>::iterator iter = emission_list.begin();
1152 (iter->f2)(&result);
1155 emission_list.erase(iter);
1160 #ifdef CGU_USE_SCHED_YIELD
1170 template <
class FreeArg>
1232 std::list<ListItem> local_list;
1235 local_list = emission_list;
1240 typename std::list<ListItem>::const_iterator iter;
1241 for (iter = local_list.begin(); iter != local_list.end(); ++iter) {
1242 if (!iter->blocked) iter->f1(arg);
1246 template <
class FreeArg>
1249 std::list<ListItem> local_list;
1252 if (emission_list.empty())
return false;
1253 local_list = emission_list;
1258 typename std::list<ListItem>::const_iterator iter;
1259 for (iter = local_list.begin(); iter != local_list.end(); ++iter) {
1260 if (!iter->blocked) iter->f1(arg);
1265 template <
class FreeArg>
1269 std::list<ListItem> tmp;
1272 emission_list.splice(emission_list.end(), tmp);
1276 template <
class FreeArg>
1294 std::list<ListItem> tmp;
1295 tmp.push_back(ListItem(f1, f2));
1296 Thread::Mutex::Lock lock(mutex);
1297 emission_list.splice(emission_list.end(), tmp);
1306 template <
class FreeArg>
1319 typename std::list<ListItem>::iterator iter = emission_list.begin();
1321 iter = std::find_if(iter, emission_list.end(),
1322 std::bind2nd(std::ptr_fun(Pred::pred), arg));
1323 if (iter != emission_list.end()) {
1326 (iter->f2)(&result);
1329 iter = emission_list.erase(iter);
1334 #ifdef CGU_USE_SCHED_YIELD
1342 iter = emission_list.begin();
1352 template <
class FreeArg>
1362 Thread::Mutex::Lock lock(mutex);
1363 typename std::list<ListItem>::iterator iter = emission_list.begin();
1365 iter = std::find_if(iter, emission_list.end(),
1366 std::bind2nd(std::ptr_fun(Pred::pred), arg));
1367 if (iter != emission_list.end()) {
1369 iter = emission_list.erase(iter);
1375 template <
class FreeArg>
1388 typename std::list<ListItem>::iterator iter = emission_list.begin();
1390 iter = std::find_if(iter, emission_list.end(),
1391 std::bind2nd(std::ptr_fun(Pred::pred), arg));
1392 if (iter != emission_list.end()) {
1393 iter->blocked =
true;
1400 template <
class FreeArg>
1413 typename std::list<ListItem>::iterator iter = emission_list.begin();
1415 iter = std::find_if(iter, emission_list.end(),
1416 std::bind2nd(std::ptr_fun(Pred::pred), arg));
1417 if (iter != emission_list.end()) {
1418 iter->blocked =
false;
1425 #ifndef DOXYGEN_PARSING
1450 f1(f1_), f2(f2_), blocked(false) {}
1453 std::list<ListItem> emission_list;
1482 template <
class FreeArg1,
class FreeArg2>
1483 class EmitterArg <TypeTuple<FreeArg1, FreeArg2> > {
1485 Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2> > f1;
1488 ListItem(Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2> > f1_,
Callback::Functor f2_):
1489 f1(f1_), f2(f2_), blocked(false) {}
1492 std::list<ListItem> emission_list;
1494 void tracking_disconnect(Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2> >);
1511 Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2> >
connect(
const Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2> >& f);
1512 Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2> >
connect(
const Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2> >& f,
Releaser& r);
1513 void disconnect(
const Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2> >& f);
1515 void block(
const Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2> >& f);
1516 void unblock(
const Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2> >& f);
1526 template <
class FreeArg1,
class FreeArg2>
1527 EmitterArg<TypeTuple<FreeArg1, FreeArg2> >::~EmitterArg() {
1529 struct DisconnectReleaserItem {
1530 static void exec(
const ListItem& l) {(l.f2)();}
1532 std::for_each(emission_list.begin(), emission_list.end(),
1536 template <
class FreeArg1,
class FreeArg2>
1539 std::list<ListItem> local_list = emission_list;
1541 typename std::list<ListItem>::const_iterator iter;
1542 for (iter = local_list.begin(); iter != local_list.end(); ++iter) {
1543 if (!iter->blocked) iter->f1(arg1, arg2);
1547 template <
class FreeArg1,
class FreeArg2>
1550 if (emission_list.empty())
return false;
1555 template <
class FreeArg1,
class FreeArg2>
1556 Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2> > EmitterArg<TypeTuple<FreeArg1, FreeArg2> >::connect(
const Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2> >& f1) {
1561 template <
class FreeArg1,
class FreeArg2>
1562 Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2> > EmitterArg<TypeTuple<FreeArg1, FreeArg2> >::connect(
const Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2> >& f1, Releaser& r) {
1574 emission_list.push_back(ListItem(f1, f2));
1583 template <
class FreeArg1,
class FreeArg2>
1584 void EmitterArg<TypeTuple<FreeArg1, FreeArg2> >::disconnect(
const Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2> >& arg) {
1586 static bool pred(ListItem p, Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2> > f) {
1591 typename std::list<ListItem>::iterator iter = emission_list.begin();
1593 iter = std::find_if(iter, emission_list.end(),
1594 std::bind2nd(std::ptr_fun(Pred::pred), arg));
1595 if (iter != emission_list.end()) {
1597 iter = emission_list.erase(iter);
1603 template <
class FreeArg1,
class FreeArg2>
1604 void EmitterArg<TypeTuple<FreeArg1, FreeArg2> >::tracking_disconnect(Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2> > arg) {
1606 static bool pred(ListItem p, Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2> > f) {
1611 typename std::list<ListItem>::iterator iter = emission_list.begin();
1613 iter = std::find_if(iter, emission_list.end(),
1614 std::bind2nd(std::ptr_fun(Pred::pred), arg));
1615 if (iter != emission_list.end()) {
1616 iter = emission_list.erase(iter);
1622 template <
class FreeArg1,
class FreeArg2>
1623 void EmitterArg<TypeTuple<FreeArg1, FreeArg2> >::block(
const Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2> >& arg) {
1625 static bool pred(ListItem p, Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2> > f) {
1630 typename std::list<ListItem>::iterator iter = emission_list.begin();
1632 iter = std::find_if(iter, emission_list.end(),
1633 std::bind2nd(std::ptr_fun(Pred::pred), arg));
1634 if (iter != emission_list.end()) {
1635 iter->blocked =
true;
1642 template <
class FreeArg1,
class FreeArg2>
1643 void EmitterArg<TypeTuple<FreeArg1, FreeArg2> >::unblock(
const Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2> >& arg) {
1645 static bool pred(ListItem p, Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2> > f) {
1650 typename std::list<ListItem>::iterator iter = emission_list.begin();
1652 iter = std::find_if(iter, emission_list.end(),
1653 std::bind2nd(std::ptr_fun(Pred::pred), arg));
1654 if (iter != emission_list.end()) {
1655 iter->blocked =
false;
1662 template <
class FreeArg1,
class FreeArg2,
class FreeArg3>
1663 class EmitterArg <TypeTuple<FreeArg1, FreeArg2, FreeArg3> > {
1665 Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> > f1;
1668 ListItem(Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> > f1_,
Callback::Functor f2_):
1669 f1(f1_), f2(f2_), blocked(false) {}
1672 std::list<ListItem> emission_list;
1674 void tracking_disconnect(Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >);
1684 emit(arg1, arg2, arg3);
1694 Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >
connect(
const Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >& f);
1695 Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >
connect(
const Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >& f,
Releaser& r);
1696 void disconnect(
const Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >& f);
1698 void block(
const Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >& f);
1699 void unblock(
const Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >& f);
1709 template <
class FreeArg1,
class FreeArg2,
class FreeArg3>
1710 EmitterArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >::~EmitterArg() {
1712 struct DisconnectReleaserItem {
1713 static void exec(
const ListItem& l) {(l.f2)();}
1715 std::for_each(emission_list.begin(), emission_list.end(),
1719 template <
class FreeArg1,
class FreeArg2,
class FreeArg3>
1723 std::list<ListItem> local_list = emission_list;
1725 typename std::list<ListItem>::const_iterator iter;
1726 for (iter = local_list.begin(); iter != local_list.end(); ++iter) {
1727 if (!iter->blocked) iter->f1(arg1, arg2, arg3);
1731 template <
class FreeArg1,
class FreeArg2,
class FreeArg3>
1735 if (emission_list.empty())
return false;
1736 emit(arg1, arg2, arg3);
1740 template <
class FreeArg1,
class FreeArg2,
class FreeArg3>
1741 Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> > EmitterArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >::connect(
const Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >& f1) {
1746 template <
class FreeArg1,
class FreeArg2,
class FreeArg3>
1747 Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> > EmitterArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >::connect(
const Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >& f1, Releaser& r) {
1759 emission_list.push_back(ListItem(f1, f2));
1768 template <
class FreeArg1,
class FreeArg2,
class FreeArg3>
1769 void EmitterArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >::disconnect(
const Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >& arg) {
1771 static bool pred(ListItem p, Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> > f) {
1776 typename std::list<ListItem>::iterator iter = emission_list.begin();
1778 iter = std::find_if(iter, emission_list.end(),
1779 std::bind2nd(std::ptr_fun(Pred::pred), arg));
1780 if (iter != emission_list.end()) {
1782 iter = emission_list.erase(iter);
1788 template <
class FreeArg1,
class FreeArg2,
class FreeArg3>
1789 void EmitterArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >::tracking_disconnect(Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> > arg) {
1791 static bool pred(ListItem p, Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> > f) {
1796 typename std::list<ListItem>::iterator iter = emission_list.begin();
1798 iter = std::find_if(iter, emission_list.end(),
1799 std::bind2nd(std::ptr_fun(Pred::pred), arg));
1800 if (iter != emission_list.end()) {
1801 iter = emission_list.erase(iter);
1807 template <
class FreeArg1,
class FreeArg2,
class FreeArg3>
1808 void EmitterArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >::block(
const Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >& arg) {
1810 static bool pred(ListItem p, Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> > f) {
1815 typename std::list<ListItem>::iterator iter = emission_list.begin();
1817 iter = std::find_if(iter, emission_list.end(),
1818 std::bind2nd(std::ptr_fun(Pred::pred), arg));
1819 if (iter != emission_list.end()) {
1820 iter->blocked =
true;
1827 template <
class FreeArg1,
class FreeArg2,
class FreeArg3>
1828 void EmitterArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >::unblock(
const Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >& arg) {
1830 static bool pred(ListItem p, Callback::FunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> > f) {
1835 typename std::list<ListItem>::iterator iter = emission_list.begin();
1837 iter = std::find_if(iter, emission_list.end(),
1838 std::bind2nd(std::ptr_fun(Pred::pred), arg));
1839 if (iter != emission_list.end()) {
1840 iter->blocked =
false;
1850 class SafeEmitterArg<void> {
1853 Callback::SafeFunctorArg<int*> f2;
1856 f1(f1_), f2(f2_), blocked(false) {}
1859 std::list<ListItem> emission_list;
1860 mutable Thread::Mutex mutex;
1889 template <
class FreeArg1,
class FreeArg2>
1890 class SafeEmitterArg <TypeTuple<FreeArg1, FreeArg2> > {
1892 Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2> > f1;
1893 Callback::SafeFunctorArg<int*> f2;
1895 ListItem(Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2> > f1_, Callback::SafeFunctorArg<int*> f2_):
1896 f1(f1_), f2(f2_), blocked(false) {}
1899 std::list<ListItem> emission_list;
1900 mutable Thread::Mutex mutex;
1902 void tracking_disconnect(Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2> >);
1919 Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2> >
connect(
const Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2> >& f);
1920 Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2> >
connect(
const Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2> >& f,
Releaser& r);
1921 void disconnect(
const Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2> >& f);
1923 void block(
const Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2> >& f);
1924 void unblock(
const Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2> >& f);
1934 template <
class FreeArg1,
class FreeArg2>
1935 SafeEmitterArg<TypeTuple<FreeArg1, FreeArg2> >::~SafeEmitterArg() {
1936 Thread::Mutex::Lock lock(mutex);
1937 while (!emission_list.empty()) {
1938 typename std::list<ListItem>::iterator iter = emission_list.begin();
1940 (iter->f2)(&result);
1942 emission_list.erase(iter);
1946 #ifdef CGU_USE_SCHED_YIELD
1956 template <
class FreeArg1,
class FreeArg2>
1959 std::list<ListItem> local_list;
1961 Thread::Mutex::Lock lock(mutex);
1962 local_list = emission_list;
1965 typename std::list<ListItem>::const_iterator iter;
1966 for (iter = local_list.begin(); iter != local_list.end(); ++iter) {
1967 if (!iter->blocked) iter->f1(arg1, arg2);
1971 template <
class FreeArg1,
class FreeArg2>
1974 std::list<ListItem> local_list;
1976 Thread::Mutex::Lock lock(mutex);
1977 if (emission_list.empty())
return false;
1978 local_list = emission_list;
1981 typename std::list<ListItem>::const_iterator iter;
1982 for (iter = local_list.begin(); iter != local_list.end(); ++iter) {
1983 if (!iter->blocked) iter->f1(arg1, arg2);
1988 template <
class FreeArg1,
class FreeArg2>
1989 Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2> > SafeEmitterArg<TypeTuple<FreeArg1, FreeArg2> >::connect(
const Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2> >& f1) {
1990 std::list<ListItem> tmp;
1991 tmp.push_back(ListItem(f1, Callback::SafeFunctorArg<int*>()));
1992 Thread::Mutex::Lock lock(mutex);
1993 emission_list.splice(emission_list.end(), tmp);
1997 template <
class FreeArg1,
class FreeArg2>
1998 Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2> > SafeEmitterArg<TypeTuple<FreeArg1, FreeArg2> >::connect(
const Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2> >& f1, Releaser& r) {
2010 std::list<ListItem> tmp;
2011 tmp.push_back(ListItem(f1, f2));
2012 Thread::Mutex::Lock lock(mutex);
2013 emission_list.splice(emission_list.end(), tmp);
2022 template <
class FreeArg1,
class FreeArg2>
2023 void SafeEmitterArg<TypeTuple<FreeArg1, FreeArg2> >::disconnect(
const Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2> >& arg) {
2025 static bool pred(ListItem p, Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2> > f) {
2030 Thread::Mutex::Lock lock(mutex);
2031 typename std::list<ListItem>::iterator iter = emission_list.begin();
2033 iter = std::find_if(iter, emission_list.end(),
2034 std::bind2nd(std::ptr_fun(Pred::pred), arg));
2035 if (iter != emission_list.end()) {
2037 (iter->f2)(&result);
2039 iter = emission_list.erase(iter);
2043 #ifdef CGU_USE_SCHED_YIELD
2049 iter = emission_list.begin();
2056 template <
class FreeArg1,
class FreeArg2>
2057 void SafeEmitterArg<TypeTuple<FreeArg1, FreeArg2> >::tracking_disconnect(Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2> > arg) {
2059 static bool pred(ListItem p, Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2> > f) {
2064 Thread::Mutex::Lock lock(mutex);
2065 typename std::list<ListItem>::iterator iter = emission_list.begin();
2067 iter = std::find_if(iter, emission_list.end(),
2068 std::bind2nd(std::ptr_fun(Pred::pred), arg));
2069 if (iter != emission_list.end()) {
2070 iter = emission_list.erase(iter);
2076 template <
class FreeArg1,
class FreeArg2>
2077 void SafeEmitterArg<TypeTuple<FreeArg1, FreeArg2> >::block(
const Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2> >& arg) {
2079 static bool pred(ListItem p, Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2> > f) {
2084 Thread::Mutex::Lock lock(mutex);
2085 typename std::list<ListItem>::iterator iter = emission_list.begin();
2087 iter = std::find_if(iter, emission_list.end(),
2088 std::bind2nd(std::ptr_fun(Pred::pred), arg));
2089 if (iter != emission_list.end()) {
2090 iter->blocked =
true;
2097 template <
class FreeArg1,
class FreeArg2>
2098 void SafeEmitterArg<TypeTuple<FreeArg1, FreeArg2> >::unblock(
const Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2> >& arg) {
2100 static bool pred(ListItem p, Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2> > f) {
2105 Thread::Mutex::Lock lock(mutex);
2106 typename std::list<ListItem>::iterator iter = emission_list.begin();
2108 iter = std::find_if(iter, emission_list.end(),
2109 std::bind2nd(std::ptr_fun(Pred::pred), arg));
2110 if (iter != emission_list.end()) {
2111 iter->blocked =
false;
2118 template <
class FreeArg1,
class FreeArg2,
class FreeArg3>
2119 class SafeEmitterArg <TypeTuple<FreeArg1, FreeArg2, FreeArg3> > {
2121 Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> > f1;
2122 Callback::SafeFunctorArg<int*> f2;
2124 ListItem(Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> > f1_, Callback::SafeFunctorArg<int*> f2_):
2125 f1(f1_), f2(f2_), blocked(false) {}
2128 std::list<ListItem> emission_list;
2129 mutable Thread::Mutex mutex;
2131 void tracking_disconnect(Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >);
2141 emit(arg1, arg2, arg3);
2151 Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >
connect(
const Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >& f);
2152 Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >
connect(
const Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >& f,
Releaser& r);
2153 void disconnect(
const Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >& f);
2155 void block(
const Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >& f);
2156 void unblock(
const Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >& f);
2166 template <
class FreeArg1,
class FreeArg2,
class FreeArg3>
2167 SafeEmitterArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >::~SafeEmitterArg() {
2168 Thread::Mutex::Lock lock(mutex);
2169 while (!emission_list.empty()) {
2170 typename std::list<ListItem>::iterator iter = emission_list.begin();
2172 (iter->f2)(&result);
2174 emission_list.erase(iter);
2178 #ifdef CGU_USE_SCHED_YIELD
2188 template <
class FreeArg1,
class FreeArg2,
class FreeArg3>
2192 std::list<ListItem> local_list;
2194 Thread::Mutex::Lock lock(mutex);
2195 local_list = emission_list;
2198 typename std::list<ListItem>::const_iterator iter;
2199 for (iter = local_list.begin(); iter != local_list.end(); ++iter) {
2200 if (!iter->blocked) iter->f1(arg1, arg2, arg3);
2204 template <
class FreeArg1,
class FreeArg2,
class FreeArg3>
2208 std::list<ListItem> local_list;
2210 Thread::Mutex::Lock lock(mutex);
2211 if (emission_list.empty())
return false;
2212 local_list = emission_list;
2215 typename std::list<ListItem>::const_iterator iter;
2216 for (iter = local_list.begin(); iter != local_list.end(); ++iter) {
2217 if (!iter->blocked) iter->f1(arg1, arg2, arg3);
2222 template <
class FreeArg1,
class FreeArg2,
class FreeArg3>
2223 Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> > SafeEmitterArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >::connect(
const Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >& f1) {
2224 std::list<ListItem> tmp;
2225 tmp.push_back(ListItem(f1, Callback::SafeFunctorArg<int*>()));
2226 Thread::Mutex::Lock lock(mutex);
2227 emission_list.splice(emission_list.end(), tmp);
2231 template <
class FreeArg1,
class FreeArg2,
class FreeArg3>
2232 Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> > SafeEmitterArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >::connect(
const Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >& f1, Releaser& r) {
2244 std::list<ListItem> tmp;
2245 tmp.push_back(ListItem(f1, f2));
2246 Thread::Mutex::Lock lock(mutex);
2247 emission_list.splice(emission_list.end(), tmp);
2256 template <
class FreeArg1,
class FreeArg2,
class FreeArg3>
2257 void SafeEmitterArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >::disconnect(
const Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >& arg) {
2259 static bool pred(ListItem p, Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> > f) {
2264 Thread::Mutex::Lock lock(mutex);
2265 typename std::list<ListItem>::iterator iter = emission_list.begin();
2267 iter = std::find_if(iter, emission_list.end(),
2268 std::bind2nd(std::ptr_fun(Pred::pred), arg));
2269 if (iter != emission_list.end()) {
2271 (iter->f2)(&result);
2273 iter = emission_list.erase(iter);
2277 #ifdef CGU_USE_SCHED_YIELD
2283 iter = emission_list.begin();
2290 template <
class FreeArg1,
class FreeArg2,
class FreeArg3>
2291 void SafeEmitterArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >::tracking_disconnect(Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> > arg) {
2293 static bool pred(ListItem p, Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> > f) {
2298 Thread::Mutex::Lock lock(mutex);
2299 typename std::list<ListItem>::iterator iter = emission_list.begin();
2301 iter = std::find_if(iter, emission_list.end(),
2302 std::bind2nd(std::ptr_fun(Pred::pred), arg));
2303 if (iter != emission_list.end()) {
2304 iter = emission_list.erase(iter);
2310 template <
class FreeArg1,
class FreeArg2,
class FreeArg3>
2311 void SafeEmitterArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >::block(
const Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >& arg) {
2313 static bool pred(ListItem p, Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> > f) {
2318 Thread::Mutex::Lock lock(mutex);
2319 typename std::list<ListItem>::iterator iter = emission_list.begin();
2321 iter = std::find_if(iter, emission_list.end(),
2322 std::bind2nd(std::ptr_fun(Pred::pred), arg));
2323 if (iter != emission_list.end()) {
2324 iter->blocked =
true;
2331 template <
class FreeArg1,
class FreeArg2,
class FreeArg3>
2332 void SafeEmitterArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >::unblock(
const Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> >& arg) {
2334 static bool pred(ListItem p, Callback::SafeFunctorArg<TypeTuple<FreeArg1, FreeArg2, FreeArg3> > f) {
2339 Thread::Mutex::Lock lock(mutex);
2340 typename std::list<ListItem>::iterator iter = emission_list.begin();
2342 iter = std::find_if(iter, emission_list.end(),
2343 std::bind2nd(std::ptr_fun(Pred::pred), arg));
2344 if (iter != emission_list.end()) {
2345 iter->blocked =
false;
2352 #endif // DOXYGEN_PARSING