Re: Can a Multi-Threaded GTKMM Application Use std::thread Rather Than Glib::Thread?
- From: Chris Gordon-Smith <c gordonsmith gmail com>
- To: Harry van Haaren <harryhaaren gmail com>
- Cc: GTKmm <gtkmm-list gnome org>
- Subject: Re: Can a Multi-Threaded GTKMM Application Use std::thread Rather Than Glib::Thread?
- Date: Sun, 16 Oct 2011 19:44:53 +0100
Hello Harry
Thanks for the response.
What I want to do is minimise the dependencies that my code has on
various libraries other than the C++ standard library.
Since the C++ standard library does not include a GUI, I use GTKMM,
which I'm very happy with. I have separated out my GUI presentation code
from the rest of the code, and only the GUI presentation code has to
include <gtkmm.h>. But to get the multithreading for the GUI working, I
have now had to introduce a dependency on Glib <glibmm.h> in other parts
of my code. I have used wrapper classes to limit the scope of the
dependency to a small section of code, but I would have preferred not to
do this at all.
My question is: Could I have avoided use of Glib::Thread altogether, and
just used std::thread?
I think probably not, but thought I would ask.
Chris Gordon-Smith
www.simsoup.info
On Sun, 2011-10-16 at 17:44 +0100, Harry van Haaren wrote:
> Hi Chris,
>
> From experience: Of course it is, if you 1. mutex critical sections
> or 2. lock-free ringbuffer all events between the threads, there's
> no reason you can't use 2 (or more) different "types" of threads in
> one app.
>
> From a practical point of view, why would you? Glib::Thread should
> suffice for simulator / GUI separation...
>
> Perhaps I'm not following your use-case, or maybe you want to play
> with the latest-and-greatest, I don't know.
> I know there's some convenience things around std::thread that you
> might want for ease of use.. but I've always
> coded those myself..
>
> -Harry
>
> On Sun, Oct 16, 2011 at 4:28 PM, Chris Gordon-Smith
> <c gordonsmith gmail com> wrote:
> Hello All
>
> I have recently introduced multi-threading into my artificial
> chemistry
> simulator, so that the GUI can be active while the simulation
> is
> running.
>
> To do this, I've used Glib::Thread. Now that C++11 provides
> threading
> with std::thread, I would prefer to use that. Is it possible
> to use
> std::thread so that I have one thread for my GTKMM GUI, and
> one (or
> more) for my simulation processing?
>
> Chris Gordon-Smith
> www.simsoup.info
>
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]