2013-02-03 13:11:16 +00:00
|
|
|
#ifndef THREAD_UTILS_H_INCLUDED
|
|
|
|
#define THREAD_UTILS_H_INCLUDED
|
|
|
|
|
2013-02-20 05:10:38 +00:00
|
|
|
#include "boost/asio.hpp"
|
2013-02-03 13:11:16 +00:00
|
|
|
#include "boost/signal.hpp"
|
|
|
|
#include "boost/thread.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
namespace SE
|
|
|
|
{
|
2013-02-20 05:10:38 +00:00
|
|
|
|
|
|
|
extern boost::asio::io_service MainThreadIoService;
|
|
|
|
|
2013-02-19 12:37:56 +00:00
|
|
|
#ifndef UTILS_ENGINE
|
2013-02-21 08:35:47 +00:00
|
|
|
|
2013-02-03 13:11:16 +00:00
|
|
|
struct TFuncToPerform
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
public:
|
|
|
|
|
|
|
|
TFuncToPerform()
|
|
|
|
: LockerPtr(new boost::mutex)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
std::shared_ptr<boost::mutex> LockerPtr;
|
|
|
|
|
|
|
|
boost::function<void()> Func;
|
2013-02-21 08:35:47 +00:00
|
|
|
};
|
2013-02-03 13:11:16 +00:00
|
|
|
void AssertIfInMainThread();
|
2013-02-03 21:24:01 +00:00
|
|
|
|
|
|
|
void TryUpdateMainThreadId();
|
|
|
|
|
2013-02-03 13:11:16 +00:00
|
|
|
void PerformInMainThreadAsync(boost::function<void()> f);
|
|
|
|
|
|
|
|
template<typename RETURNTYPE>
|
|
|
|
RETURNTYPE PerformInMainThread(boost::function<RETURNTYPE()> f);
|
|
|
|
|
2013-02-19 12:37:56 +00:00
|
|
|
#endif
|
|
|
|
|
2013-02-03 13:11:16 +00:00
|
|
|
} //namespace SE
|
|
|
|
|
|
|
|
#endif
|