Re: Multi-threading
- From: "Douglas C. MacKenzie" <doug mobile-intelligence com>
- To: bob fis-cal com
- Cc: Gtkmm Mailing List <gtkmm-list gnome org>
- Subject: Re: Multi-threading
- Date: Wed, 05 Apr 2006 15:37:50 -0400
One issue to remember is that GTK is not thread safe.
You must use a semaphore to make sure each access
to GTK is complete before another is allowed to start.
Doug
On Wed, 2006-04-05 at 14:00 -0500, Bob Caryl wrote:
> Greetings everyone:
>
> Here I am with another of my stupid questions: I am currently working
> on an application whose purpose is to demonstrate an ability to
> communicate with the credit card processing servers operated by British
> Petroluem (BP) in this country. One of the things I must do is "listen"
> for "device requests" issued by their EPS device. All these
> communications are done via TCP/IP over a local lan.
>
> Since these device requests can arrive on a particular port at any time,
> I have set up a pthread type thread to establish a listening socket on
> that port. When this thread's call to accept() returns a good socket I
> spawn another thread that is a one shot affair to receive the actual
> request and deal with it. It is in this second thread that I am running
> into trouble.
>
> What I want to do (for now) is take the actual message arriving from the
> BP EPS and display it in a Gtk::TextView by inserting it into the
> Gtk::TextBuffer associated with the view. So, I have made the function
> used to spawn the second thread a friend of my window class and I make
> the call to Gtk::TextBuffer::insert in that second thread. Here is
> where the problems arise. If I do a standard "wait for the main loop"
> device e.g.
>
> while(Gtk::Main::events_pending())
> Gtk::Main::iteration();
>
> I get the following stderr output:
>
> GLib-ERROR **: file gmain.c: line 1898 (g_main_dispatch): assertion
> failed: (source) aborting...
> Terminated with signal 6 (Aborted)
>
> Can anyone give me a hint as to my error(s) here? I am calling the
> Gtk::Main methods from a thread twice removed from the one that actually
> started that instance of Gtk::Main... Perhaps should I use
> Glib::ThreadPool rather than pthreads?
>
> All comments will be greatly appreciated,
>
> Bob Caryl
> _______________________________________________
> 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]