Re: g_threads_enter() equivalent




So where they use g_threads_enter and leave I can just replace those with a dedicated mutex that is shared only between those two threads.  Do you think it would be a better idea instead of creating a thread building the picbuf and destroying the thread that I create a thread signal it to build the pixbuf and then have it wait to be signaled again.


2010/5/7 Mark Roberts <gtkmm manumark de>
Dear Talguy,


On Thu, 2010-05-06 at 16:20 -0400, Talguy wrote:
I was wondering if there is an equivalent function to
g_threads_enter()/leave() in gtkmm.  Is gtkmm thread aware like gtk+
is.  Reason why I would like to know is I want to port the multi
threaded animation example of cairo's site to gtkmm to better help me
out in my animations.

http://cairographics.org/threaded_animation_with_cairo/

There are not equivalent functions for those in gtkmm.  However, there
are thread capabilities in glibmm that might be used to achieve similar
results (though from posts on this list using threads in gtkmm might not
be very straightforward).  There are thread examples that can be used as
reference points:

http://library.gnome.org/devel/glibmm/stable/examples.html
--
José

The C++ way with pairs of functions like g_threads_enter() and g_threads_leave() is using objects of utility classes like Glib::Mutex::Lock. The constructor locks, the destructor unlocks. This makes your program exception safe, because the destructor will not be forgotten.

There is a list of thread related utility classes here:

http://library.gnome.org/devel/glibmm/unstable/group__Threads.html

There is an example that uses Glib::Mutex::Lock here:

http://library.gnome.org/devel/glibmm/stable/thread_2thread_8cc-example.html

Hope this helps,
Mark



--
HAHA
   From Evan


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]