From: hreba <hreba@terra.com.br>
Subject: Re: GTK and tasking (GNAT)
Date: Sun, 04 May 2014 15:10:18 -0300
Date: 2014-05-04T15:10:18-03:00 [thread overview]
Message-ID: <bsne4cFsavdU1@mid.individual.net> (raw)
In-Reply-To: <lyeh0ablqi.fsf@pushface.org>
On 05/03/2014 06:23 PM, Simon Wright wrote:
> hreba <hreba@terra.com.br> writes:
>
>> accept StartCounter (txtBox: Gtk.GEntry.Gtk_Entry) do
>> for i in 1..10 loop
>> Gtk.GEntry.Set_Text (txtBox, Integer'Image(i));
>> Gtk.Widget.Queue_Draw (Gtk.Widget.Gtk_Widget(txtBox));
>> delay 0.5;
>> end loop;
>> end StartCounter;
>
> The calling task (probably the Gtk main loop) blocks while the body of
> the accept statement is executed.
>
> I don't know how this ought to be done in Gtk, though I strongly suspect
> it's not like that! However, the way to deal with the task problem would
> normally be to save the values passed with the accept and deal with them
> afterward:
>
> accept StartCounter (txtBox: Gtk.GEntry.Gtk_Entry) do
> txtBoxCopy := txtBox;
> end StartCounter;
> -- Now the caller can carry on while we work with the passed value.
> for i in 1..10 loop
> Gtk.GEntry.Set_Text (txtBoxCopy, Integer'Image(i));
> Gtk.Widget.Queue_Draw (Gtk.Widget.Gtk_Widget(txtBoxCopy));
> delay 0.5;
> end loop;
>
> Questions: is Gtk thread-safe? is Queue_Draw something that should only
> be called from the Gtk event queue?
>
I didn't expect that my first excursion into GUI programming (GTK) with
Ada would confront me with tasking and lead me into the cliffs of
thread-safety.
I am no software engineer, unfortunately I cannot answer these questions.
So I will have a look at Dimitry's library.
Thanks for the answer.
--
Frank Hrebabetzky +55 / 48 / 3235 1106
Florianopolis, Brazil
next prev parent reply other threads:[~2014-05-04 18:10 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-03 20:30 GTK and tasking (GNAT) hreba
2014-05-03 21:23 ` Simon Wright
2014-05-04 18:10 ` hreba [this message]
2014-05-04 18:29 ` Simon Wright
2014-05-04 22:10 ` hreba
2014-05-04 7:31 ` Dmitry A. Kazakov
2014-05-04 18:36 ` hreba
2014-05-04 19:26 ` Dmitry A. Kazakov
2014-05-04 20:40 ` hreba
2014-05-04 21:07 ` Shark8
2014-05-04 21:32 ` hreba
2014-05-04 21:44 ` Shark8
2014-05-04 21:57 ` hreba
2014-05-05 7:33 ` Dmitry A. Kazakov
2014-05-06 12:43 ` hreba
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox