This macro demonstrate usage of ROOT7 graphics from many threads Three different canvases in three different threads are started and regularly updated.
Extra thread created in background and used to run http protocol, in/out websocket communications and process http requests Main application thread (CLING interactive session) remains fully functional
#include <thread>
void draw_canvas(const std::string &title, RColor col)
{
RAxisConfig xaxis(100, -10., 10.);
auto pHist = std::make_shared<RH1D>(xaxis);
auto pHist2 = std::make_shared<RH1D>(xaxis);
for (
int n = 0;
n < 10000; ++
n) {
pHist->Fill(px - 2);
pHist2->Fill(py + 2);
}
auto canvas = RCanvas::Create(title + " canvas");
canvas->Draw(pHist)->AttrLine().SetColor(col);
int maxloop = 50;
canvas->Show();
printf("%s started\n", title.c_str());
for (int loop = 0; loop < maxloop; ++loop) {
for (
int n = 0;
n < 10000; ++
n) {
pHist->Fill(px - 2);
pHist2->Fill(py + 2);
}
canvas->Modified();
canvas->Update();
canvas->Run(0.5);
}
printf("%s completed\n", title.c_str());
canvas->Remove();
}
void draw_mt()
{
RWebWindowsManager::Instance();
thrd1.join();
thrd2.join();
thrd3.join();
}
#define R__LOAD_LIBRARY(LIBRARY)
virtual void SetValue(const char *name, const char *value, EEnvLevel level=kEnvChange, const char *type=0)
Set the value of a resource or create a new resource.
Random number generator class based on M.
virtual void Rannor(Float_t &a, Float_t &b)
Return 2 numbers distributed following a gaussian with mean=0 and sigma=1.
void EnableThreadSafety()
Enables the global mutex to make ROOT thread safe/aware.
- Date
- 2018-08-16
- Warning
- This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
- Author
- Sergey Linev
Definition in file draw_mt.cxx.