From ffa21ad3da117f03b3b47e5b9d7d57be49243dc1 Mon Sep 17 00:00:00 2001 From: Sergey Linev <S.Linev@gsi.de> Date: Fri, 17 Aug 2018 16:17:10 +0200 Subject: [PATCH] webgui: introduce TWebWindow::Run(double) method It allows to run webwindow functionality in non-main thread. When no connection exists - just do sleep for specified time. Should be regularly called --- gui/webdisplay/inc/ROOT/TWebWindow.hxx | 2 ++ gui/webdisplay/inc/ROOT/TWebWindowsManager.hxx | 4 ++-- gui/webdisplay/src/TWebWindow.cxx | 13 +++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/gui/webdisplay/inc/ROOT/TWebWindow.hxx b/gui/webdisplay/inc/ROOT/TWebWindow.hxx index b6aca0f04f3..f628b9bd572 100644 --- a/gui/webdisplay/inc/ROOT/TWebWindow.hxx +++ b/gui/webdisplay/inc/ROOT/TWebWindow.hxx @@ -210,6 +210,8 @@ public: void Sync(); + void Run(double tm = 0.); + bool Show(const std::string &where = ""); bool CanSend(unsigned connid, bool direct = true); diff --git a/gui/webdisplay/inc/ROOT/TWebWindowsManager.hxx b/gui/webdisplay/inc/ROOT/TWebWindowsManager.hxx index 50c015ec393..445c221975f 100644 --- a/gui/webdisplay/inc/ROOT/TWebWindowsManager.hxx +++ b/gui/webdisplay/inc/ROOT/TWebWindowsManager.hxx @@ -44,9 +44,9 @@ private: std::string fAddr; ///<! HTTP address of the server std::mutex fMutex; ///<! main mutex to protect int fMutexBooked{0}; ///<! flag indicating that mutex is booked for some long operation - std::thread::id fBookedThrd; ///<! thread where mutex is booked, can be reused + std::thread::id fBookedThrd; ///<! thread where mutex is booked, can be reused + unsigned fIdCnt{0}; ///<! counter for identifiers // std::list<std::shared_ptr<TWebWindow>> fDisplays; ///<! list of existing displays (not used at the moment) - unsigned fIdCnt{0}; ///<! counter for identifiers bool CreateHttpServer(bool with_http = false); diff --git a/gui/webdisplay/src/TWebWindow.cxx b/gui/webdisplay/src/TWebWindow.cxx index 519975de2c0..ae915ec2510 100644 --- a/gui/webdisplay/src/TWebWindow.cxx +++ b/gui/webdisplay/src/TWebWindow.cxx @@ -773,3 +773,16 @@ int ROOT::Experimental::TWebWindow::WaitFor(WebWindowWaitFunc_t check, double ti { return fMgr->WaitFor(*this, check, timelimit); } + +///////////////////////////////////////////////////////////////////////////////// +/// Run window functionality for specified time +/// If no action can be performed - just sleep specified time + +void ROOT::Experimental::TWebWindow::Run(double tm) +{ + if (tm <= 0) { + Sync(); + } else { + WaitFor([](double) { return 0; }, tm); + } +} -- GitLab