6#ifndef __WVDELAYEDCALLBACK_H
7#define __WVDELAYEDCALLBACK_H
9#include "wvistreamlist.h"
29template<
class Functor>
35 wv::function<void()> frozen;
38 WvDelayedCallback(
const Functor& _func):
39 func(_func), stream(new WvStream), frozen(0)
41 WvIStreamList::globallist.append(stream,
true,
"WvDelayedCallback");
43 WvDelayedCallback(
const WvDelayedCallback &other):
44 func(other.func), stream(new WvStream), frozen(0)
46 WvIStreamList::globallist.append(stream,
true,
"WvDelayedCallback");
54 stream->setcallback(func);
58 void operator()(P1 &p1)
60 stream->setcallback(wv::bind(func, p1));
65 void operator()(P1 &p1, P2 &p2)
67 stream->setcallback(wv::bind(func, p1, p2));
73 void operator()(P1 &p1, P2 &p2, P3 &p3)
75 stream->setcallback(wv::bind(func, p1, p2, p3));
82 void operator()(P1 &p1, P2 &p2, P3 &p3, P4 &p4)
84 stream->setcallback(wv::bind(func, p1, p2, p3, p4));
92 void operator()(P1 &p1, P2 &p2, P3 &p3, P4 &p4, P5 &p5)
94 stream->setcallback(wv::bind(func, p1, p2, p3, p4, p5));
103 void operator()(P1 &p1, P2 &p2, P3 &p3, P4 &p4, P5 &p5, P6 &p6)
105 stream->setcallback(wv::bind(func, p1, p2, p3, p4, p5, p6));
108 template<
typename P1,
115 void operator()(P1 &p1, P2 &p2, P3 &p3, P4 &p4, P5 &p5, P6 &p6, P7 &p7)
117 stream->setcallback(wv::bind(func, p1, p2, p3, p4, p5, p6, p7));
120 template<
typename P1,
128 void operator()(P1 &p1, P2 &p2, P3 &p3, P4 &p4, P5 &p5, P6 &p6, P7 &p7,
131 stream->setcallback(wv::bind(func, p1, p2, p3, p4, p5, p6, p7, p8));
151 template <
typename T>
152 inline T delayed(T cb)
154 return WvDelayedCallback<T>(cb);
165 template <
typename T>
166 inline wv::function<T> delayed(T *cb)
168 return WvDelayedCallback< wv::function<T> >(cb);
A WvCallback wrapper that delays until the next tick of the WvIStreamList main loop.