Added try_implicit_cast<>() to check callbacks validness at run time

This commit is contained in:
Pavel Kirienko
2014-03-09 13:47:07 +04:00
parent 0afb7f4eea
commit 1659b5c476
3 changed files with 43 additions and 3 deletions
+7 -2
View File
@@ -66,13 +66,18 @@ public:
TimerEventForwarder(Scheduler& node, Functor functor)
: Timer(node)
, functor_(functor)
{ }
{
assert(try_implicit_cast<bool>(functor, true));
}
const Functor& getFunctor() const { return functor_; }
void onTimerEvent(const TimerEvent& event)
{
functor_(event);
if (try_implicit_cast<bool>(functor_, true))
functor_(event);
else
assert(0);
}
};