in reply to Parallel download Tk

This looks like a use case for threads.
use threads; my @data; if ($UseDataOne eq 1){ push @data, async { [ GetDataOne(@TableParameters) ] }; } if ($UseDatatwo eq 1){ push @data, async { [ GetDatatwo(@TableParameters) ] }; } if ($UseDataThree eq 1){ push @data, async { [ GetDataThree(@TableParameters) ] }; } if ($UseDataFour eq 1){ push @data, async { [ GetDataFour(@TableParameters) ] }; } @data = map { $_->join } @data;
Now @data is an array of arrays containing your portions of data.

Replies are listed 'Best First'.
Re^2: Parallel download Tk
by karlgoethebier (Abbot) on Dec 31, 2018 at 10:11 UTC

    As far as i remember Tk isn‘t really thread-safe. Please correct me if i‘m wrong. Regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

    perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

      Tk isn't thread safe, but there are ways how to use it with threads safely - basically, load it into one thread only (which means require instead of use) and don't share anything from it. For an example, see PM::CB::G.

      map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
Re^2: Parallel download Tk
by Takamoto (Monk) on Dec 31, 2018 at 09:20 UTC

    A least on Windows (I will try later on macOS), it always fires errors like:

    Attempt to free nonexistent shared string 'Tk::Button=HASH(0x88256ec)' +, Perl interpreter: 0x8b06784 at C:/berrybrew/5.28.0_32/perl/site/lib +/Tk/Balloon.pm line 150 during global destruction. Free to wrong pool 8a89560 not c69f50 at C:/berrybrew/5.28.0_32/perl/s +ite/lib/Tk/Widget.pm line 363 during global destruction.

    From the first thread to the last one (and merging of all arrays) nothing happens with the GUI and no Tk code involved in the subroutines (the GUI may also freeze which is okay in may case).

      Sorry about that. Tk being non thread-safe does, indeed, complicate things.