logo       

Re: WxPerl, Scandeps, and Threads: msg#00053

Subject: Re: WxPerl, Scandeps, and Threads
are you sharing the variables you need for communication before you
create the thread?  If you use my in a BEGIN block it gets undef'ed 
see my example

#!/usr/bin/perl

$bar = 1;
sleep 1;
$bar = 0;
undef $bar;
for ($i = 0;$i < 10;$i++)
    {
    print "String i is $i\n\n";
    }
undef $foo;
#sleep 2; #  this causes a strange exceptin on winblows.
BEGIN
    {
    use threads;
    use threads::shared;
    # create global variable foo
    $foo = 1;
    # my $foo : shared = 1; #  this will become undef'ed as soon as
the BEGIN is finished
    $bar = 0;
    share ($foo);
    share ($bar);
    $thr = threads->new(
        sub
                {
                $count = 0;
                while($foo)
                        {
                        if ($bar)
                                {
                                print "\rcount: $count";
                                }
                        $count++;
                        }
                print "thread closing\n\n";
                })->detach();
    }

    

On Mon, 12 Jul 2004 17:36:14 +0200, Pavel <du4mi@xxxxxx> wrote:
> Hello Jesse,
> 
> Monday, July 12, 2004, 5:10:40 PM, you wrote:
> 
> JS> Scandeps doesn't seem to be doing the trick with WxPerl.  I needed
> >>pp -M Wx -M Wx::App -M Wx::DND -M  Wx::DocView -M Wx::FS -M Wx::Grid
> JS> -M Wx::Help -M Wx::Html -M Wx::MDI -M Wx::Print -M Wx::Socket -M
> JS> Wx::Calendar  -o foo.exe foo.pl
> 
> JS> Also for those thread guru's out there.  Is there a better way to deal
> JS> with "thread bloat" and OO syntax (e.g. use base (<PKG>);)?  Right now
> JS> I'm using a BEGIN{} block so the other imported packages don't get
> JS> Cloned into my thread.  My begin block is working fine, but because
> JS> I'm using a global variable to tell my thread to shutdown nicely, I
> JS> get scalar leaks.  I'd like my worker thread to be as small as
> JS> possible, so if you guys have any tricks for that I'd appreciate it.
> JS> I played with Thread::Needs a bit, but its kind of scary.  Is there a
> JS> good way to unload a module loaded with use?
> 
> JS> Great job on Par guys, it's my favorite package.
> 
> JS> -jess
> 
> sorry for offlist. I have written some gui-programms that use thread and
> tryed to start thread without any module loaded in BEGIN block. But so
> this thread and main programm cannt communicate with each other.
> I have post this question already many times, but got no right
> answers. May be you will have more luck.
> my posts were:
> http://www.google.com/search?num=100&hl=en&q=du4mi+%28threads+OR+ithreads%29
> 
> please tell me if you solve this problem
> 
> Thanks in advance!
> 
> --
> Best regards,
>  Pavel                            mailto:du4mi@xxxxxx
> 
>



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
boot-loaders.gr...    php.pear.genera...    debugging.valgr...    kde.redhat.user...    text.xml.xsl.ge...    culture.languag...    hardware.microc...    java.servicemix...    redhat.release....    web.zope.plone....    user-groups.lin...    opendarwin.webk...    video.mjpeg.use...    sysutils.bcfg2....    encryption.gpg....    lx-office.devel...    xfree86.forum/2...    mail.mutt.devel...    acpi.devel/2003...    qnx.openqnx.dev...    network.irc.irs...    freebsd.devel.m...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe