On Sep 7, 2008, at 3:53 PM, Nick Zitzmann wrote:
On Sep 7, 2008, at 4:39 PM, Jean-Daniel Dupas wrote:You can use perform on main thread using a class method and pass your structure as argument.That worked; thanks. I wouldn't have guessed it, since that method wasn't documented as a class method, but it worked anyway...
Code Fragment:
Just a idea like that.You can use perform on main thread using a class method and pass your structure as argument.+ (void)finalize {[[self class] performSelectorOnMainThread:@selector(destroyNotThreadSafeStruct:) withObject:[NSValue valueWithPointer:myStruct]];} + (void)destroyNotThreadSafeStruct:(id)myStruct { void *struct = [myStruct pointerValue];// perform cleanup. As this is a class method, it does not resurect the object.}
Yup. That is the way to do it. Whatever you do, *do not block in your -finalize methods*. Especially if you blocking on main thread processing.
Very Bad Things Can Happen.Notably, your performance can go to hell. And it is quite easy to lock things up.
In this case, the above pattern should not cause that to happen.In general, -finalize should *only be used to release memory not being managed by GC*.
b.bum
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]