10 messages in com.mysql.lists.ndb-connectorsRe: [Fwd: Re: [Swig-user] C++ wrappin...
FromSent OnAttachments
Monty Taylor07 May 2007 14:52 
Mika Raento07 May 2007 23:37 
Monty Taylor08 May 2007 00:06 
Mika Raento08 May 2007 00:21 
Monty Taylor08 May 2007 00:46 
Mika Raento08 May 2007 00:57 
Mika Raento08 May 2007 01:27 
Mika Raento08 May 2007 01:58 
Mika Raento08 May 2007 03:36 
Monty Taylor08 May 2007 11:05 
Subject:Re: [Fwd: Re: [Swig-user] C++ wrapping question]
From:Mika Raento (mik@iki.fi)
Date:05/08/2007 12:21:19 AM
List:com.mysql.lists.ndb-connectors

Monty Taylor wrote:

Mika Raento wrote:

Here's some info about refcounting... it looks like we need to explore %refcount and %unrefcount

Hm. I don't think it's that simple. The %refcount stuff assumes your C++ objects are refcounted. Which the Ndb objects aren't. Which is why I've been toying with the idea of hooking into the reference counting/gc of the target languages. But that may not be possible in any realistic way.

Indeed, you are right.

There are only a few things that need to get refcounted - Ndb, NdbTransaction, NdbOperation... and even then it's unlikely that you let the Ndb go out of scope. So maybe hooking in language level refcounting wouldn't be too terrible.

I'm looking into the target-language option. Basically what is needed to do that is to:

1. in each target language, have a place to stash the extra reference (e.g., a module level hash in perl) 2. shadow startTransaction/asynchPrepare to stash an extra reference to Ndb/Ndb+transaction (NdbOperations are owned by the transaction) 3. shadow close/callback to remove the extra reference

Out of these 3. is the only one I'm not sure how to do. I have to find out whether you can shadow the destructor. Shadowing the callback will already give a place to keep the extra reference: create another closure around the callback given by the user-level program that maintains a reference.

It's just a pain that we (well, you, I only care about perl for the moment :-) have to do it for each target language separately.

Mika