You could create a class derived from TCanvas, such as:
class MyCanvas : public TCanvas {
MyCanvas(args) : TCanvas(args) {}
UpdateHistogram(h) { Lockguard...};
TMutex fGuiMutex{};
}
Another option is to derive from TGMainFrame and then have a private member with a TRootEmbeddedCanvas. See full example here: Oscilloscope class for binary waveforms 16-bit - #3 by ferhue
But the first option is simpler.