Changeset 11063


Ignore:
Timestamp:
03/11/10 03:05:36 (2 years ago)
Author:
rehsack
Message:

Update thread-finish code to wait real for 2 minutes and don't guess
how long a sleep(2) really takes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Padre/lib/Padre/TaskManager.pm

    r11060 r11063  
    7676use threads::shared; 
    7777use Thread::Queue 2.11; 
     78use Time::HiRes qw(gettimeofday tv_interval); 
    7879 
    7980require Padre; 
     
    426427    $self->task_queue->insert( 0, ("STOP") x scalar(@workers) ); 
    427428 
    428     my $loopcount; 
     429    my $waitstart = [gettimeofday()]; 
    429430 
    430431    # Changing the selection seems to solve the endless-loop problem 
     
    434435            $_->join; 
    435436        } 
    436         last    if $loopcount > 125; # Wait no more than two minutes 
    437                                      # Pass time slices to the threads for finishing 
    438         sleep 1 if ++$loopcount > 5; 
     437 
     438        # Wait no more than two minutes 
     439        last    if( tv_interval($waitstart) >= (2*60) ); 
     440 
     441        # Pass time slices to the threads for finishing 
     442        threads->yield(); 
    439443    } 
    440444 
Note: See TracChangeset for help on using the changeset viewer.