305 #ifdef CGU_USE_SCHED_YIELD
312 #include <unordered_set>
314 #include <functional>
316 #include <type_traits>
326 template <
class... FreeArgs>
class EmitterArg;
327 template <
class... FreeArgs>
class SafeEmitterArg;
358 std::unordered_set<Callback::SafeFunctor> disconnect_set;
495 template <
class... FreeArgs>
498 #ifndef DOXYGEN_PARSING
507 f1(f1_), f2(f2_), blocked(
false) {}
511 std::list<ListItem> emission_list;
605 class =
typename std::enable_if<!std::is_convertible<typename std::remove_reference<F>::type,
608 return connect(Callback::lambda<FreeArgs...>(std::forward<F>(f)));
636 class =
typename std::enable_if<!std::is_convertible<typename std::remove_reference<F>::type,
639 return connect(Callback::lambda<FreeArgs...>(std::forward<F>(f)), r);
704 template <
class... FreeArgs>
706 for(
const auto& l: emission_list) {l.f2();}
709 template <
class... FreeArgs>
741 std::list<ListItem> local_list = emission_list;
743 for (
const auto& l: local_list) {
744 if (!l.blocked) l.f1(args...);
748 template <
class... FreeArgs>
750 if (emission_list.empty())
return false;
755 template <
class... FreeArgs>
761 template <
class... FreeArgs>
774 emission_list.emplace_back(f1, f2);
783 template <
class... FreeArgs>
787 auto iter = emission_list.begin();
789 iter = std::find_if(iter, emission_list.end(),
790 [&arg](
const ListItem& p) ->
bool {return p.f1 == arg;});
791 if (iter != emission_list.end()) {
796 iter = emission_list.erase(iter);
805 template <
class... FreeArgs>
807 auto iter = emission_list.begin();
809 iter = std::find_if(iter, emission_list.end(),
810 [&arg](
const ListItem& p) ->
bool {return p.f1 == arg;});
811 if (iter != emission_list.end()) {
813 iter = emission_list.erase(iter);
819 template <
class... FreeArgs>
823 auto iter = emission_list.begin();
825 iter = std::find_if(iter, emission_list.end(),
826 [&arg](
const ListItem& p) ->
bool {return p.f1 == arg;});
827 if (iter != emission_list.end()) {
828 iter->blocked =
true;
835 template <
class... FreeArgs>
839 auto iter = emission_list.begin();
841 iter = std::find_if(iter, emission_list.end(),
842 [&arg](
const ListItem& p) ->
bool {return p.f1 == arg;});
843 if (iter != emission_list.end()) {
844 iter->blocked =
false;
921 template <
class... FreeArgs>
924 #ifndef DOXYGEN_PARSING
933 f1(f1_), f2(f2_), blocked(
false) {}
937 std::list<ListItem> emission_list;
1038 class =
typename std::enable_if<!std::is_convertible<typename std::remove_reference<F>::type,
1041 return connect(Callback::lambda<FreeArgs...>(std::forward<F>(f)));
1069 class =
typename std::enable_if<!std::is_convertible<typename std::remove_reference<F>::type,
1072 return connect(Callback::lambda<FreeArgs...>(std::forward<F>(f)), r);
1146 template <
class... FreeArgs>
1153 while (!emission_list.empty()) {
1154 auto iter = emission_list.begin();
1157 (iter->f2)(&result);
1160 emission_list.erase(iter);
1165 #ifdef CGU_USE_SCHED_YIELD
1175 template <
class... FreeArgs>
1237 std::list<ListItem> local_list;
1240 local_list = emission_list;
1243 for (
const auto& l: local_list) {
1244 if (!l.blocked) l.f1(args...);
1248 template <
class... FreeArgs>
1251 std::list<ListItem> local_list;
1254 if (emission_list.empty())
return false;
1255 local_list = emission_list;
1258 for (
const auto& l: local_list) {
1259 if (!l.blocked) l.f1(args...);
1264 template <
class... FreeArgs>
1270 emission_list.splice(emission_list.end(), std::move(tmp));
1274 template <
class... FreeArgs>
1292 std::list<ListItem> tmp{ListItem{f1, f2}};
1294 emission_list.splice(emission_list.end(), std::move(tmp));
1303 template <
class... FreeArgs>
1308 auto iter = emission_list.begin();
1310 iter = std::find_if(iter, emission_list.end(),
1311 [&arg](
const ListItem& p) ->
bool {return p.f1 == arg;});
1312 if (iter != emission_list.end()) {
1315 (iter->f2)(&result);
1318 iter = emission_list.erase(iter);
1323 #ifdef CGU_USE_SCHED_YIELD
1331 iter = emission_list.begin();
1341 template <
class... FreeArgs>
1344 auto iter = emission_list.begin();
1346 iter = std::find_if(iter, emission_list.end(),
1347 [&arg](
const ListItem& p) ->
bool {return p.f1 == arg;});
1348 if (iter != emission_list.end()) {
1350 iter = emission_list.erase(iter);
1356 template <
class... FreeArgs>
1361 auto iter = emission_list.begin();
1363 iter = std::find_if(iter, emission_list.end(),
1364 [&arg](
const ListItem& p) ->
bool {return p.f1 == arg;});
1365 if (iter != emission_list.end()) {
1366 iter->blocked =
true;
1373 template <
class... FreeArgs>
1378 auto iter = emission_list.begin();
1380 iter = std::find_if(iter, emission_list.end(),
1381 [&arg](
const ListItem& p) ->
bool {return p.f1 == arg;});
1382 if (iter != emission_list.end()) {
1383 iter->blocked =
false;