recycle signal slots

master
Daniel Kolesa 2015-07-16 19:21:51 +01:00
parent 8327022c67
commit 58cbe3873c
1 changed files with 5 additions and 0 deletions

View File

@ -43,6 +43,11 @@ namespace detail {
template<typename F>
Size connect(F &&func) {
using Func = Function<void(C &, A...)>;
for (Size i = 0; i < p_nfuncs; ++i)
if (!p_funcs[i]) {
p_funcs[i] = forward<F>(func);
return i;
}
Func *nbuf = (Func *)new byte[sizeof(Func) * (p_nfuncs + 1)];
for (Size i = 0; i < p_nfuncs; ++i) {
new (&nbuf[i]) Func(move(p_funcs[i]));