Re: Gtkmm thread example
- From: "Dave Foster" <dave foster gmail com>
- Cc: gtkmm-list gnome org
- Subject: Re: Gtkmm thread example
- Date: Fri, 6 Jun 2008 11:27:45 -0400
Argh, forgot to reply to all, copypaste occurs:
Hi -
You've found the correct classes to use here.
This might be just what I need but the example is glibmm and I don't know how
to adapt to a gtkmm.
The
example you found is a bit confusing as it does not show how it fits in
with gtkmm, and it's a bit long to be a simple example, but that's
probably because there's not a lot to using a dispatcher.
Here's a breakdown:
- from your main thread (the UI thread), connect your dispatcher to a callback function via connect()
-
start your second thread (the hardware polling thread), and in that,
use the emit() or simply <dispatcher_name>() on the dispatcher
instance to cause the dispatcher to fire, which means your main thread
will run the signal handler you connected in step one.
However, this does not solve everything. Presumably you want your
hardware thread to provide some data to the UI thread, which the
dispatcher does not provide. You have to use some data structure that
is common between them, and protect that data structure with a mutex,
locking before access and unlocking after.
Hopefully that is enough to get you going..
dave
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]