Changeset 323

Show
Ignore:
Timestamp:
03/04/08 21:10:13 (9 months ago)
Author:
jake
Message:

fixed thread saftey issue

Location:
trunk/thrudex
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/thrudex/src/CLuceneIndex.cpp

    r320 r323  
    156156        modifier->flush(); 
    157157 
    158         ram_searcher  = shared_ptr<IndexSearcher>(new IndexSearcher( ram_directory.get() )); 
     158        ram_searcher.reset(new IndexSearcher( ram_directory.get() )); 
    159159 
    160160        //since clucene doesn't use shared_ptr we need to get the 
     
    165165 
    166166        if(syncing){ 
    167             ram_prev_searcher  = shared_ptr<IndexSearcher>(new IndexSearcher( ram_prev_directory.get() )); 
     167            ram_prev_searcher.reset(new IndexSearcher( ram_prev_directory.get() )); 
    168168            searchers[2] = ram_prev_searcher.get(); 
    169169            searchers[3] = NULL; 
     
    172172        } 
    173173 
    174         searcher  = shared_ptr<MultiSearcher>( new MultiSearcher( searchers ) ); 
     174        searcher.reset( new MultiSearcher( searchers ) ); 
    175175 
    176176        last_refresh = Util::currentTime(); 
     
    279279    } 
    280280 
     281 
     282    //making sure references to underlying objects stay above 0 
     283    //for the duration of this function 
     284    shared_ptr<CLuceneRAMDirectory> l_ram_directory      = ram_directory; 
    281285    shared_ptr<CLuceneRAMDirectory> l_ram_prev_directory = ram_prev_directory; 
     286    shared_ptr<IndexSearcher>       l_ram_searcher       = ram_searcher; 
     287    shared_ptr<IndexSearcher>       l_ram_prev_searcher  = ram_prev_searcher; 
     288    shared_ptr<IndexSearcher>       l_disk_searcher      = disk_searcher; 
     289 
    282290 
    283291    shared_ptr<MultiSearcher> l_searcher    = this->getSearcher(); 
  • trunk/thrudex/src/Thrudex.thrift

    r259 r323  
    11cpp_namespace thrudex 
    22php_namespace Thrudex 
     3ruby_namespace Thrudex 
    34perl_package  Thrudex 
    45java_package  thrudex 
  • trunk/thrudex/test/Makefile

    r263 r323  
    1111 
    1212all: ../src/Thrudex.thrift 
    13         $(THRIFT) -perl ../src/Thrudex.thrift 
     13        $(THRIFT) -perl -rb ../src/Thrudex.thrift 
    1414 
    1515clean: 
    16         rm -fr gen-perl 
     16        rm -fr gen-perl gen-rb 
  • trunk/thrudex/test/aol-query.pl

    r300 r323  
    3737        $i++; 
    3838 
     39 
    3940        if( $i % 100 == 0 ){ 
    4041            print "Found ".$r->total."\n"; 
     
    4243 
    4344    } 
    44  
    4545 
    4646    $transport->close(); 
  • trunk/thrudex/test/dup-test.pl

    r300 r323  
    1414 
    1515use Thrudex; 
     16use Time::HiRes qw(gettimeofday); 
    1617 
    1718my $socket    = new Thrift::Socket('localhost',9099); 
     
    1920my $protocol  = new Thrift::BinaryProtocol($transport); 
    2021my $client    = new ThrudexClient($protocol); 
     22 
    2123 
    2224my $index  = shift; 
     
    4850 
    4951    my $i = 0; 
     52    my $last_i = 0; 
     53    my $t0 = gettimeofday(); 
     54 
    5055    while(1){ 
    5156        my $r = $client->search( $q ); 
    5257        $i++; 
    5358 
    54         if($r->total == 2){ 
     59        if($r->total > 1){ 
    5560            die "Found ".$r->total."\n"; 
    5661        }elsif($i % 1000){ 
    57             print "Found ".$r->total."\n"; 
     62            #print "Found ".$r->total."\n"; 
    5863        } 
    5964 
    60         print $client->put($d); 
     65 
     66        my $t1 = gettimeofday(); 
     67 
     68        if(($t1 - $t0) > 1){ 
     69 
     70            warn(($i - $last_i)." loops in ".sprintf("%0.2f",($t1-$t0))."sec, $i total\n"); 
     71 
     72            $t0       = $t1; 
     73 
     74            $last_i   = $i; 
     75        } 
     76 
     77        #print $client->put($d); 
    6178    } 
    6279