[Mono-dev] Embedded: storing extra data on objects?
dmitchell at logos.com
Tue Mar 31 12:17:44 EDT 2009
Robert Jordan wrote:
> David Mitchell wrote:
>> When embedding mono, is there a way to store a little bit of extra
>> information (pointer-sized) along with a MonoObject (or similar
>> My scenario is that I have unmanaged wrappers for managed objects, and
>> like to ensure that there is never more than one unmanaged wrapper per
>> object (and also be able to get the unmanaged wrapper if all I have is
>> object). I¹m sure I know that I could use a hash table for this, and that
>> may end up being what I do, but actually storing the pointer on the
>> MonoObject seems more natural, in my case.
> I wonder why your wrapper must have 1:1 relationship with the object
> it wraps.
I'm working on a bridging scenario between Objective C and Mono that is not
addressed by existing solutions.
> Supposing you really need this 1:1 relationship, how do you handle the
> liveness of the wrapper? If there is only one pointer to its instance,
> it will go away together with the MonoObject when the latter gets
> garbage collected, so you won't be able to free it.
The wrapper has an unpinned gchandle to the object, so the MonoObject won't
be garbage collected until I release the wrapper--whose lifetime is handled
by Objective C code.
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
View this message in context: http://www.nabble.com/Embedded%3A-storing-extra-data-on-objects--tp22787556p22805218.html
Sent from the Mono - Dev mailing list archive at Nabble.com.
More information about the Mono-devel-list