From: Plum, Jason <jplum@ba...> - 2006-04-07 14:15:15
Jez is correct. There are definitely what *appear* to be really complex
things going on in threads, but Rob's ThreadUtils helps to make it quite
simple for most programs.
I've got my own little system I use for some programs (which I am far
from ready to release for public use as its currently a bit of a memory
hog) that has some funky cross thread data and object passing, but its
probably the kind of thing that is only needed in very specific
instances where Rob's code won't do. For example a 6 thread system that
in reality is a layered and peer system of threads each handling their
own work but sharing certain complete non-XS object data across say, 3
threads at a time. This is a rather uncommon approach to a threading
system as usually one would simply have a worker/boss or pipeline
system, which ThreadUtils works great for.
[mailto:perl-win32-gui-users-admin@...] On Behalf Of
Sent: Friday, April 07, 2006 4:53 AM
To: orasnita@...; perl-win32-gui-users@...
Subject: RE: [perl-win32-gui-users] sharing objects
>I am trying to create a program using Win32::GUI that uses more=20
>threads. A few threads should connect to a server and download data=20
>permanently, and other threads should updated some list views with that
>For doing this I need to use threads::shared and share some variables=20
>like $Win and other variables like $ListView, but if I try to share=20
>them I get errors like:
>Invalid value for shared scalar at program.pl line 19.
>Are there any examples of using threads with objects, references that=20
>could help me learn how to use threads with Win32::GUI?
The best place to start is to download the thread utils module that Roy
May has built:
This makes interthread communication much more straightforward.
The best way to share Win32-GUI objects is to share the handle, not the
actual object itself, but my advice is try to only have one thread
dealing with the GUI. For example:
Say you've got five threads downloading data, and five listviews that
you want to update. Rather than have the five threads update the
listview directly, they send a message back to the parent thread (which
is dealing with the gui) with the data for the list view. Although it
sounds complicated, it's easy with Rob's code.
This SF.Net email is sponsored by xPML, a groundbreaking scripting
language that extends applications into web and mobile media. Attend the
live webcast and join the prime developer group breaking into this new
Perl-Win32-GUI-Users mailing list