Skip to content
Snippets Groups Projects
Commit a4eb63af authored by Sergey Linev's avatar Sergey Linev
Browse files

[webgui] let reassign main thread id

If application runs in special thread, one should
call RWebWindowManager::AssignMainThrd() to indicate this
parent 7d4c58d4
Branches
Tags
No related merge requests found
...@@ -57,8 +57,6 @@ private: ...@@ -57,8 +57,6 @@ private:
int WaitFor(RWebWindow &win, WebWindowWaitFunc_t check, bool timed = false, double tm = -1); int WaitFor(RWebWindow &win, WebWindowWaitFunc_t check, bool timed = false, double tm = -1);
static bool IsMainThrd();
std::string GetUrl(const RWebWindow &win, bool remote = false); std::string GetUrl(const RWebWindow &win, bool remote = false);
bool CreateServer(bool with_http = false); bool CreateServer(bool with_http = false);
...@@ -79,6 +77,9 @@ public: ...@@ -79,6 +77,9 @@ public:
std::shared_ptr<RWebWindow> CreateWindow(); std::shared_ptr<RWebWindow> CreateWindow();
void Terminate(); void Terminate();
static bool IsMainThrd();
static void AssignMainThrd();
}; };
} // namespace Experimental } // namespace Experimental
......
...@@ -67,12 +67,28 @@ static std::thread::id gWebWinMainThrd = std::this_thread::get_id(); ...@@ -67,12 +67,28 @@ static std::thread::id gWebWinMainThrd = std::this_thread::get_id();
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
/// Returns true when called from main process /// Returns true when called from main process
/// Main process recognized at the moment when library is loaded /// Main process recognized at the moment when library is loaded
/// It supposed to be a thread where gApplication->Run() will be called
/// If application runs in separate thread, one have to use AssignMainThrd() method
/// to let RWebWindowsManager correctly recognize such situation
bool RWebWindowsManager::IsMainThrd() bool RWebWindowsManager::IsMainThrd()
{ {
return std::this_thread::get_id() == gWebWinMainThrd; return std::this_thread::get_id() == gWebWinMainThrd;
} }
//////////////////////////////////////////////////////////////////////////////////////////
/// Re-assigns main thread id
/// Normally main thread id recognized at the moment when library is loaded
/// It supposed to be a thread where gApplication->Run() will be called
/// If application runs in separate thread, one have to call this method
/// to let RWebWindowsManager correctly recognize such situation
void RWebWindowsManager::AssignMainThrd()
{
gWebWinMainThrd = std::this_thread::get_id();
}
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
/// window manager constructor /// window manager constructor
/// Required here for correct usage of unique_ptr<THttpServer> /// Required here for correct usage of unique_ptr<THttpServer>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment