Changeset 33533

Show
Ignore:
Timestamp:
05/23/09 22:18:26 (6 years ago)
Author:
kazuho
Message:

switch to rwlock

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/DBIx-Distributed/trunk/lib/DBIx/Distributed/Driver/Direct.pm

    r33530 r33533  
    238238 
    239239sub _exec_sql { 
    240     my ($self, $params, $cb, $sql, @values) = @_; 
    241     # obtain database handle (and lock) 
    242     $self->_dbh($self->driver->find_dbh_cb->($self->_dtable, $self->key)) 
    243         unless $self->_dbh; 
     240    my ($self, $params, $is_read, $sql, @values) = @_; 
    244241    # record sql 
    245242    $self->driver->_record_sql($sql, @values); 
    246243    my $attr = $params->{attr} || {}; 
    247     $cb ||= sub { 
    248         $self->_dbh->do(@_); 
    249     }; 
    250     $cb->($sql, $attr, @values); 
     244    # obtain database handle (and lock) 
     245    $self->_dbh( 
     246        $self->driver->find_dbh_cb->($self->_dtable, $self->key, $is_read), 
     247    ) unless $self->_dbh; 
     248    # execute 
     249    if ($is_read) { 
     250        return $self->_dbh->selectall_arrayref($sql, $attr, @values); 
     251    } else { 
     252        return $self->_dbh->do($sql, $attr, @values); 
     253    } 
    251254} 
    252255