forked from OctaForge/libostd
recycle signal slots
parent
8327022c67
commit
58cbe3873c
|
@ -43,6 +43,11 @@ namespace detail {
|
||||||
template<typename F>
|
template<typename F>
|
||||||
Size connect(F &&func) {
|
Size connect(F &&func) {
|
||||||
using Func = Function<void(C &, A...)>;
|
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)];
|
Func *nbuf = (Func *)new byte[sizeof(Func) * (p_nfuncs + 1)];
|
||||||
for (Size i = 0; i < p_nfuncs; ++i) {
|
for (Size i = 0; i < p_nfuncs; ++i) {
|
||||||
new (&nbuf[i]) Func(move(p_funcs[i]));
|
new (&nbuf[i]) Func(move(p_funcs[i]));
|
||||||
|
|
Loading…
Reference in New Issue