mirror of
https://github.com/Kiritow/MiniEngine.git
synced 2024-03-22 13:11:22 +08:00
Add void timer function support. (without metaprogramming)
This commit is contained in:
parent
1641dbf4bc
commit
3e2479e216
14
MiniEngine.h
14
MiniEngine.h
|
@ -467,11 +467,21 @@ namespace MiniEngine
|
|||
{
|
||||
public:
|
||||
Timer();
|
||||
/// Uint32 func(Uint32,void*) ...
|
||||
|
||||
/// void func(Uint32,...)
|
||||
template<typename VoidCallable,typename... Args>
|
||||
Timer(Uint32 interval,VoidCallable&& vcallable,Args&&... args) : Timer()
|
||||
{
|
||||
auto realCall=[&](Uint32 ims)->Uint32{vcallable(ims,args...);return interval;};
|
||||
auto pfunc=new std::function<Uint32(Uint32 interval)>(realCall);
|
||||
_real_timer_call(_global_timer_executor,interval,pfunc);
|
||||
}
|
||||
|
||||
/// Uint32 func(Uint32,...)
|
||||
template<typename Callable,typename... Args>
|
||||
Timer(Callable&& callable,Uint32 interval,Args&&... args) : Timer()
|
||||
{
|
||||
auto realCall=[&](Uint32 interval)->Uint32{return callable(interval,args...);};
|
||||
auto realCall=[&](Uint32 ims)->Uint32{return callable(ims,args...);};
|
||||
auto pfunc=new std::function<Uint32(Uint32 interval)>(realCall);
|
||||
_real_timer_call(_global_timer_executor,interval,pfunc);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user