Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Is gtkmm thread-safe?

gtkmm safe thread
0
10 Posted

Is gtkmm thread-safe?

0

Paul Davis wrote: Neither X, nor GDK nor GTK+ nor gtkmm are thread safe by themselves. You must use either the gdk_threads_{enter,leave}() functions to protect any and every call to GDK/GTK+/gtkmm functions, or alternatively, ensure that only a single thread makes such calls. One common way to do this is to have non-GUI threads send requests to the GUI thread via a pipe. The pipe is hooked into the main glib event loop used by GTK. Personally, i have always used the single-threaded approach, which I find much more suitable for my apps. Note that glibmm comes with Glib::Dispatcher, which implements a cross-thread signal using the pipe approach described above. Andreas Rottmann added: If you need a more sophisticated cross-thread message-passing approach, take a look at libsigc++ extras. It provides cross-thread, typesafe slot invocation on top of libsigc++ and comes with a gtkmm example.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123