Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
Merge pull request #32 from SiminBadri/patch-5
Browse files Browse the repository at this point in the history
Update w_timer_callback.h
  • Loading branch information
PooyaEimandar authored Jul 31, 2020
2 parents d5f2cf6 + d6f0266 commit ed54f96
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions engine/src/wolf.system/w_timer_callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace wolf
class w_timer_callback
{
public:
w_timer_callback() {};
w_timer_callback():_thread(nullptr) {};
~w_timer_callback() {};

template <class T>
Expand All @@ -34,18 +34,22 @@ namespace wolf
pFunc();
}

template <class T>
void do_async(int pIntervalMilliSeconds, T&& pFunc)
template <class T, typename... Args>
void do_async(int pIntervalMilliSeconds, T&& pFunc, Args... pArgs)
{
std::thread t([pIntervalMilliSeconds, &pFunc]()
{
w_thread::sleep_current_thread(pIntervalMilliSeconds);
pFunc();
});
t.detach();
_thread = new w_thread();
_thread->add_job([pIntervalMilliSeconds, &pFunc, pArgs...]()
{
w_thread::sleep_current_thread(pIntervalMilliSeconds);
pFunc(pArgs...);
});
}

private:
w_thread* _thread;
};
}
}

#endif //__W_TIMER_CALLBACK_H__

0 comments on commit ed54f96

Please sign in to comment.