cleaned up the end-of-streaming logic

This commit is contained in:
Dima Kogan 2010-06-06 20:24:41 -07:00
parent 9bac656396
commit aed6f30b38

View File

@ -6,6 +6,7 @@ use IO::Handle;
use List::MoreUtils qw( first_index ); use List::MoreUtils qw( first_index );
use Data::Dumper; use Data::Dumper;
use threads; use threads;
use threads::shared;
use Thread::Queue; use Thread::Queue;
open(GNUPLOT_VERSION, "gnuplot --version |"); open(GNUPLOT_VERSION, "gnuplot --version |");
@ -175,6 +176,7 @@ my @curves = ();
my $dataQueue; my $dataQueue;
my $xwindow; my $xwindow;
my $streamingFinished : shared = undef;
if($options{"stream"}) if($options{"stream"})
{ {
if( defined $options{"hardcopy"}) if( defined $options{"hardcopy"})
@ -199,11 +201,10 @@ if($options{"stream"})
} }
} }
$dataQueue->enqueue("Plot now"); $streamingFinished = 1;
$dataQueue->enqueue(undef);
$addThr->join();
$plotThr->join(); $plotThr->join();
$addThr->join();
} }
else else
{ {
@ -214,11 +215,14 @@ else
sub plotThread sub plotThread
{ {
while(1) while(! $streamingFinished)
{ {
sleep(1); sleep(1);
$dataQueue->enqueue("Plot now"); $dataQueue->enqueue("Plot now");
} }
$dataQueue->enqueue(undef);
} }
sub mainThread { sub mainThread {