|
List Info
Thread: Unthreading ekiga : a strategy
|
|
| Unthreading ekiga : a strategy |
  France |
2007-04-16 06:46:06 |
Hi,
first, let me spell out that the goal isn't to get rid of
threads
entirely : that would be very stupid! No, the goal is to
make all
graphical operations happen in a single thread, so we aren't
hit by
forgotten _thread_enter/_thread_leave in our code, or
thread-unsafety in
libraries we depend on (accessibility comes to mind).
The current code in the network code looks like this :
OnFooHappens (...)
{
/* declaration of good variables */
/* declaration of gui variables */
/* good code */
/* gui code */
/* good code */
}
The first step is certainly to separate GUI code from good
code like this :
OnFooHappensGUI (...)
{
/* declaration of gui variables */
/* gui code */
}
OnFooHappens (...)
{
/* declaration of good variables */
/* good code */
OnFooHappensGUI (...);
/* good code */
}
The second step is then to re-implement the GUI functions to
push
treatment in the main thread :
OnFooHappensGUISafe (...)
{
/* declaration of gui variables */
/* gui code */
/* free nice structure */
}
OnFoHappensGUI (...)
{
/* allocate a nice structure */
/* populate with the needed data */
/* push to the main thread */
}
There are several ways the push can be done :
- the most simple way is to g_idle_add the function to call
(this is the
trick I use in my LDAP code) ;
- the most complete way is à-la-GstBus, where we have a
GSource whichs
watches a GQueue (or GAsyncQueue) and executes code from
there (there we
can probably just take the GstBus code since 1. it's been
well-tested
2. it's LGPL or GPL).
Snark
PS: this is reported here :
http
://bugzilla.gnome.org/show_bug.cgi?id=353533
_______________________________________________
Ekiga-devel-list mailing list
Ekiga-devel-list gnome.org
http://mail.gnome.org/mailman/listinfo/ekiga-devel-list
a> |
|
| Re: Unthreading ekiga : a strategy |
  Belgium |
2007-04-16 06:45:56 |
Hi,
Le lundi 16 avril 2007 à 13:46 +0200, Julien Puydt a écrit
:
> Hi,
>
> first, let me spell out that the goal isn't to get rid
of threads
> entirely : that would be very stupid! No, the goal is
to make all
> graphical operations happen in a single thread, so we
aren't hit by
> forgotten _thread_enter/_thread_leave in our code, or
thread-unsafety in
> libraries we depend on (accessibility comes to mind).
>
> The current code in the network code looks like this :
> OnFooHappens (...)
> {
> /* declaration of good variables */
> /* declaration of gui variables */
>
> /* good code */
> /* gui code */
> /* good code */
> }
>
> The first step is certainly to separate GUI code from
good code like this :
>
> OnFooHappensGUI (...)
> {
> /* declaration of gui variables */
>
> /* gui code */
> }
>
> OnFooHappens (...)
> {
> /* declaration of good variables */
>
> /* good code */
> OnFooHappensGUI (...);
> /* good code */
> }
>
> The second step is then to re-implement the GUI
functions to push
> treatment in the main thread :
> OnFooHappensGUISafe (...)
> {
> /* declaration of gui variables */
>
> /* gui code */
>
> /* free nice structure */
> }
>
> OnFoHappensGUI (...)
> {
> /* allocate a nice structure */
> /* populate with the needed data */
> /* push to the main thread */
> }
>
> There are several ways the push can be done :
> - the most simple way is to g_idle_add the function to
call (this is the
> trick I use in my LDAP code) ;
> - the most complete way is à-la-GstBus, where we have
a GSource whichs
> watches a GQueue (or GAsyncQueue) and executes code
from there (there we
> can probably just take the GstBus code since 1. it's
been well-tested
> 2. it's LGPL or GPL).
>
I think this is for post-3.00. We'll see.
However, what I have in mind is to trigger a signal, and the
interested
GUI parties listen to it.
That is the only clean approach. If you use glib, then the
GUI can not
entirely be abstracted out of the OPAL specific code.
--
_ Damien Sandras
(o-
// Ekiga Softphone : http://www.ekiga.org/
v_/_ NOVACOM : http://www.novacom.be/
FOSDEM : http://www.fosdem.org/
SIP Phone : sip:dsandras ekiga.net
_______________________________________________
Ekiga-devel-list mailing list
Ekiga-devel-list gnome.org
http://mail.gnome.org/mailman/listinfo/ekiga-devel-list
a> |
|
| Re: Unthreading ekiga : a strategy |
  France |
2007-04-16 07:03:32 |
Damien Sandras a écrit :
> I think this is for post-3.00. We'll see.
Yes, we'll see. But it aches when we debug other peoples'
threading issues!
> However, what I have in mind is to trigger a signal,
and the interested
> GUI parties listen to it.
Beware : you'll still need to go to the gui thread before
you fire the
signal!
But it's indeed the principle
> That is the only clean approach. If you use glib, then
the GUI can not
> entirely be abstracted out of the OPAL specific code.
Notice : glib isn't GUI.
I use libsigc++ for signals in my latest contact code :
http://libsigc.source
forge.net/
Snark
_______________________________________________
Ekiga-devel-list mailing list
Ekiga-devel-list gnome.org
http://mail.gnome.org/mailman/listinfo/ekiga-devel-list
a> |
|
| Re: Unthreading ekiga : a strategy |
  Belgium |
2007-04-16 07:02:33 |
Le lundi 16 avril 2007 à 14:03 +0200, Julien Puydt a écrit
:
> Damien Sandras a écrit :
> > I think this is for post-3.00. We'll see.
>
> Yes, we'll see. But it aches when we debug other
peoples' threading issues!
>
Until now, except for the accessibility issues, I have never
debugged
any threading issue related to GTK+ itself. (only deadlocks
or missing
locks in OPAL itself).
> > However, what I have in mind is to trigger a
signal, and the interested
> > GUI parties listen to it.
>
> Beware : you'll still need to go to the gui thread
before you fire the
> signal!
>
> But it's indeed the principle
>
> > That is the only clean approach. If you use glib,
then the GUI can not
> > entirely be abstracted out of the OPAL specific
code.
>
> Notice : glib isn't GUI.
>
It is still a C dependance part of GTK+.
> I use libsigc++ for signals in my latest contact code :
> http://libsigc.source
forge.net/
I think it is better :
- Endpoints fire signals
- the GUI thread listens to them and acts consequently
--
_ Damien Sandras
(o-
// Ekiga Softphone : http://www.ekiga.org/
v_/_ NOVACOM : http://www.novacom.be/
FOSDEM : http://www.fosdem.org/
SIP Phone : sip:dsandras ekiga.net
_______________________________________________
Ekiga-devel-list mailing list
Ekiga-devel-list gnome.org
http://mail.gnome.org/mailman/listinfo/ekiga-devel-list
a> |
|
| Re: Unthreading ekiga : a strategy |
  France |
2007-04-16 07:19:32 |
Damien Sandras a écrit :
> It is still a C dependance part of GTK+.
Even kde people accept a little glib
>> I use libsigc++ for signals in my latest contact
code :
>> http://libsigc.source
forge.net/
>
> I think it is better :
> - Endpoints fire signals
> - the GUI thread listens to them and acts consequently
Firing a signal happens in the firing thread. The endpoint
will still
need to push something to the gui thread, which will then
fire the signal.
Snark
_______________________________________________
Ekiga-devel-list mailing list
Ekiga-devel-list gnome.org
http://mail.gnome.org/mailman/listinfo/ekiga-devel-list
a> |
|
| Re: Unthreading ekiga : a strategy |
  Belgium |
2007-04-16 07:21:18 |
Le lundi 16 avril 2007 à 14:19 +0200, Julien Puydt a écrit
:
> Damien Sandras a écrit :
> > It is still a C dependance part of GTK+.
>
> Even kde people accept a little glib
>
> >> I use libsigc++ for signals in my latest
contact code :
> >> http://libsigc.source
forge.net/
> >
> > I think it is better :
> > - Endpoints fire signals
> > - the GUI thread listens to them and acts
consequently
>
> Firing a signal happens in the firing thread. The
endpoint will still
> need to push something to the gui thread, which will
then fire the signal.
Can't we simply fire the signal in the endpoint, and have
something
listening to it outside of it, as part of the GUI classes,
and then
triggering the appropriate signal for the GTK+ elements (in
case of a
GTK+ interface) ?
--
_ Damien Sandras
(o-
// Ekiga Softphone : http://www.ekiga.org/
v_/_ NOVACOM : http://www.novacom.be/
FOSDEM : http://www.fosdem.org/
SIP Phone : sip:dsandras ekiga.net
_______________________________________________
Ekiga-devel-list mailing list
Ekiga-devel-list gnome.org
http://mail.gnome.org/mailman/listinfo/ekiga-devel-list
a> |
|
| Re: Unthreading ekiga : a strategy |
  France |
2007-04-16 07:53:30 |
Damien Sandras a écrit :
> Le lundi 16 avril 2007 à 14:19 +0200, Julien Puydt a
écrit :
>> Damien Sandras a écrit :
>>> It is still a C dependance part of GTK+.
>> Even kde people accept a little glib
>>
>>>> I use libsigc++ for signals in my latest
contact code :
>>>> http://libsigc.source
forge.net/
>>> I think it is better :
>>> - Endpoints fire signals
>>> - the GUI thread listens to them and acts
consequently
>> Firing a signal happens in the firing thread. The
endpoint will still
>> need to push something to the gui thread, which
will then fire the signal.
>
> Can't we simply fire the signal in the endpoint, and
have something
> listening to it outside of it, as part of the GUI
classes, and then
> triggering the appropriate signal for the GTK+ elements
(in case of a
> GTK+ interface) ?
No : firing a signal means executing signal listeners. So if
you fire
the signal in a thread, you'll execute the listeners in that
very same
thread.
We will push signal emission orders somewhere, and the gui
thread will
have to fetch them there, and carry the task on.
That isn't as bad as it sounds : we could have a
toolkit-free
mutex-protected queue, push things in it, and have the
toolkit thread do
its magic to access the queue. Say we push
sigc::slot<void> objects in a
queue<sigc::slot<void> > in the endpoint (with a
mutex), and a GSource
(this is gui code, so it can use whatever it wants) picks it
there and
executes them, now in the gui thread.
Snark
_______________________________________________
Ekiga-devel-list mailing list
Ekiga-devel-list gnome.org
http://mail.gnome.org/mailman/listinfo/ekiga-devel-list
a> |
|
[1-7]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|