Skip to content
Snippets Groups Projects
Commit 0ec32d97 authored by Sergey Linev's avatar Sergey Linev Committed by Axel Naumann
Browse files

[webgui] let reassign main thread id

If application runs in special thread, one should
call RWebWindowManager::AssignMainThrd() to indicate this
parent 7966deed
No related branches found
No related tags found
No related merge requests found
...@@ -60,8 +60,6 @@ private: ...@@ -60,8 +60,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);
...@@ -82,6 +80,9 @@ public: ...@@ -82,6 +80,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
......
...@@ -69,12 +69,28 @@ static std::thread::id gWebWinMainThrd = std::this_thread::get_id(); ...@@ -69,12 +69,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 ROOT::Experimental::RWebWindowsManager::IsMainThrd() bool ROOT::Experimental::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 ROOT::Experimental::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.
Finish editing this message first!
Please register or to comment