Re: [gtkmm] 2 mainloops in 2 different threads?



Hi and thanks for the answer!

On Thu, 19 Sep 2002, P. Christeas wrote:

> > if not (and i suspect that this is the case), then you should be able
> > to just hook the database code into the GUI main loop by providing an
> > API for the library that:
> >
> >     1) exposes 1 or more file descriptors that can be polled for
> >          "read possible" or "write possible"
> >     2) callbacks to be executed when either of these conditions
> >          occurs.
> >

You are absolutly right, that this is the simpler solution if a GUI
Mainloop like Gtk::Main is present. You are also right about the time
constraint.

>
> I have done something similar. Actually, the main reason of choosing gtkmm
> instead of Qt was that gtkmm can more easily extend its main loop to include
> some custom polling algorithm. Unforunatelly I haven't ported to any recent
> gtkmm ver. still.
> There is some issues I had to deal with. One of them is that you have to
> choose between two mechanisms:
> - multi-thread, where you have to use data-locking to avoid corruption
> or
> - single-process, where you will most probably deal with re-entrancy in
> functions.
> Please ask in personal for more details.
>

I tried the single-process / re-entrancy implementation for GUI programs
in the first version of the library three years ago. Since I had to call
Gtk::Main recursively to wait for certain database events I always had to
check whether the call to Gtk::Main::quit() was the one I was looking for
or whether it came from somewhere else (windows closing, another
database event, ....), ....
IMHO: I found it to be a hassle.
My coding skills may of course be involved in this problem, but I am pretty
sure that my implementation was not that bad. Thats why I wanted to try the
other approach this time. It may not be better than my first approach,
but at least I want to give it a try. I will have to deal with other
problems you have mentioned, but I hope that the final structure of the
program will be made clearer through the separation of the two parts.

And thanks for the offer! I may come back to it later.

	Thanks to you all!

		Stephan






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