From: Donovan A. <al...@Zo...> - 2006-10-03 22:02:52
|
subs::parallel looks neat, but glancing at it, I would say be careful = with it, since stack size and var duplication might eat you alive. =20 As far as I have gone with threads in perl, a possible approach for you = is: =20 1> Launch your thread early in the code, decreasing the amount of = duplicate vars. 2> Use threads::shared or Thread::Queue::* family to share data = structures between threads 3> Setup a queue check on timer or loop iteration (or use = Thread::Queue::Monitored or Thread::Queue::Any::Monitored? - no = experience with these 2) within the threads that need to act on = new/changed data. 3b> Don't recall details atm, but I think Thread::Queue can block as = well, so you can idle until data flows in (probably a better fit for = background process blocking on GUI providing data). =20 Now, an approach I have taken is to actually pass perl code as a scalar = between threads (generating it on one end, evaling it on the other). = There are plenty of potential gotchas on this path, which I will not go = into here. =20 I would also check out: http://www.presicient.com/psiche/ =20 They offer up some good reading and some interesting modules, although = Thread::Sociable appears to be gone...possible that some of the = performance issues with threads::shared have been resolved? =20 =20 Also, have you looked at Mattia's Wx::App::MasterMind package to see how = he has done threading with Wx? I have not myself, so no clue. =20 I have used the approach I provided at the top with great success and = very nice performance with both non-GUI apps and Win32::GUI apps, but = not yet within a WxPerl app. =20 =20 I have also been hoping to write a test that uses one of the Event libs = to handle my queue watching for me. =20 Anyway, interested to know how you resolve it and any cool bits you = discover along the way. =20 ________________________________ From: wxp...@li... on behalf of Foo JH Sent: Tue 10/3/2006 2:45 AM To: Sergei Steshenko Cc: wxperl-users Subject: Re: [wxperl-users] Threading in wxPerl Hello Sergei, Thanks for the reply. I don't know if this will work. The abstraction is so clean I worry if I can control the sharing of variable at all. And to answer your question: Perl doc says that threading will duplicate ALL variables in the main thread. Sounds quite bad to me. Does any1 else do threading on wxPerl? Sergei Steshenko wrote: > --- Foo JH <jhf...@ex...> wrote: > > =20 >> Hi all, >> >> I'm trying to write an app that does work in the background, and the = gui >> will show any updates based on the background job. >> >> The thing is, Perl's threading duplicates all variables. I wonder how = in >> a new thread, I can continue to work on the control objects in the = main >> thread. >> >> Any best practice in this area is appreciated. >> >> Thanks. >> >> = -------------------------------------------------------------------------= >> Take Surveys. Earn Cash. Influence the Future of IT >> Join SourceForge.net's Techsay panel and you'll get the chance to = share your >> opinions on IT & business topics through brief surveys -- and earn = cash >> = http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3D= DEVDEV >> _______________________________________________ >> wxperl-users mailing list >> wxp...@li... >> https://lists.sourceforge.net/lists/listinfo/wxperl-users >> >> =20 > > Does Perl threading also duplicate global variables ? > > Have you considered subs::parallel - to be found as > > = http://search.cpan.org/~nilsonsfj/subs-parallel-0.07/lib/subs/parallel.pm= > > ? > > The latter, I believe, hides threads from you, so you just have to = think > how to synchronize the subroutines. > > --Sergei. > > > > > Applications From Scratch: http://appsfromscratch.berlios.de/ > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > > = -------------------------------------------------------------------------= > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to = share your > opinions on IT & business topics through brief surveys -- and earn = cash > = http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3D= DEVDEV > _______________________________________________ > wxperl-users mailing list > wxp...@li... > https://lists.sourceforge.net/lists/listinfo/wxperl-users > =20 -------------------------------------------------------------------------= Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share = your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3D= DEVDEV _______________________________________________ wxperl-users mailing list wxp...@li... https://lists.sourceforge.net/lists/listinfo/wxperl-users |