List Info

Thread: Threading




Threading
user name
2006-08-06 19:38:16
Heya...

How do I wait for a thread to join without blocking the
GUI?

like:

1) show dialog

2) start resource heavy stuff in thread

3) wait for thread to finish

4) destroy dialog

the problem is: $thread->join; blocks. my thread is still
doing
it's stuff but my GUI is (b)locked.

another idea is to use a shared boolean variable that is set
to true/false to indicate the threads status.

any hints?

jens

-- 
Jens Luedicke
web: http://perldude.de/
_______________________________________________
gtk-perl-list mailing list
gtk-perl-listgnome.org

http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Threading
user name
2006-08-06 20:14:32
* Jens Luedicke <jens.luedickegmail.com> [2006-08-06
21:40]:
> any hints?

The simplest (in some way) is if you can peform your long
task
piecemeal. Then just do it bit by bit in an idle callback.

Another option might be to fork off a child process to
perform
the heavy-duty work and have the parent listen to the child
on a
pipe. You can have Glib take care of the asynchronicity for
you
by sticking the processing code in an I/O watcher callback.

Regards,
-- 
Aristotle Pagaltzis // <http://plasmasturm.org/&g
t;
_______________________________________________
gtk-perl-list mailing list
gtk-perl-listgnome.org

http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Threading
user name
2006-08-06 21:06:35
On 8/6/06, A. Pagaltzis <pagaltzisgmx.de> wrote:
> * Jens Luedicke <jens.luedickegmail.com> [2006-08-06
21:40]:
> > any hints?
>
> The simplest (in some way) is if you can peform your
long task
> piecemeal. Then just do it bit by bit in an idle
callback.

It is for file operations within my file manager project.

It is no problem to show the dialog from within the thread,
but
destroying it leads to a crash.

> Another option might be to fork off a child process to
perform
> the heavy-duty work and have the parent listen to the
child on a
> pipe. You can have Glib take care of the asynchronicity
for you
> by sticking the processing code in an I/O watcher
callback.

I think that would be the best option. Would require some
work
to get this implemented.

Jens

-- 
Jens Luedicke
web: http://perldude.de/
_______________________________________________
gtk-perl-list mailing list
gtk-perl-listgnome.org

http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Threading
user name
2006-08-07 12:27:44
On Sun, 6 Aug 2006 21:38:16 +0200
"Jens Luedicke" <jens.luedickegmail.com> wrote:

>Heya...
>
>How do I wait for a thread to join without blocking the
>GUI?
>
>like:
>
>1) show dialog
>
>2) start resource heavy stuff in thread
>
>3) wait for thread to finish
>
>4) destroy dialog
>
>the problem is: $thread->join; blocks. my thread is
still doing
>it's stuff but my GUI is (b)locked.
>
>another idea is to use a shared boolean variable that is
set
>to true/false to indicate the threads status.
>
>any hints?

The shared boolean is the way I would do it. Have the thread
set
the boolean just before it returns (or finishes it's code
block), then
in the main thread, use a timer to test repeatedly for the
boolean, then
if boolean is true, thread->join.  That won't block.

zentara

-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.
html
_______________________________________________
gtk-perl-list mailing list
gtk-perl-listgnome.org

http://mail.gnome.org/mailman/listinfo/gtk-perl-list
[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )