List:NDB Connectors« Previous MessageNext Message »
From:Mika Raento Date:May 8 2007 10:36am
Subject:Re: [Fwd: Re: [Swig-user] C++ wrapping question]
View as plain text  
And the following (with %newobject added to 
dbFactory::createNdbClusterConnection and 
Ndb_cluster_connection::getNdb) fixes the lifetime of the cluster object:

%feature("shadow") getNdb(const char* aCatalogName="", const char* 
aSchemaName="def")
%{
     sub getNdb {
         my $self=$_[0];
         my $ndb=mysql::cluster::ndbapic::NdbClusterConnection_getNdb(@_);
         my $t=tied(%{$ndb});
         $mysql::cluster::ndbapi::ndb_connectors_owned{$t}=$self;
         return $ndb;
     }
%}

%feature("shadow") ~Ndb
%{
sub DESTROY {
     return unless $_[0]->isa('HASH');
     my $self = tied(%{$_[0]});
     return unless defined $self;
     delete $ITERATORS{$self};
     if (exists $OWNER{$self}) {
         mysql::cluster::ndbapic::delete_Ndb($self);
         delete $OWNER{$self};
     }
     delete $mysql::cluster::ndbapi::ndb_connectors_owned{$self};
}

%}

Something similar should be easies to write for the other languages?

I'm not doing patches since so much of what my code relies on is not in 
bazaar. I can do the patches when the rest of the stuff is merged.

Incrementing the refcount of the Ndb object when a transaction is 
created doesn't seem necessary, as nothing ever happens with the 
transaction unless you call methods on Ndb (execute...).

    Mika
    Mika
Thread
[Fwd: Re: [Swig-user] C++ wrapping question]Monty Taylor7 May
  • Re: [Fwd: Re: [Swig-user] C++ wrapping question]Mika Raento8 May
    • Re: [Fwd: Re: [Swig-user] C++ wrapping question]Monty Taylor8 May
      • Re: [Fwd: Re: [Swig-user] C++ wrapping question]Mika Raento8 May
        • Re: [Fwd: Re: [Swig-user] C++ wrapping question]Monty Taylor8 May
          • Re: [Fwd: Re: [Swig-user] C++ wrapping question]Mika Raento8 May
            • Re: [Fwd: Re: [Swig-user] C++ wrapping question]Mika Raento8 May
              • Re: [Fwd: Re: [Swig-user] C++ wrapping question]Mika Raento8 May
          • compilation fails from bzrMika Raento8 May
            • Re: compilation fails from bzrMonty Taylor8 May