• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Speed Traps
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Speed Traps


  • Subject: Re: Speed Traps
  • From: Greg Titus <email@hidden>
  • Date: Tue, 20 May 2003 18:52:54 -0700

On Tuesday, May 20, 2003, at 06:21 PM, Ben Dougall wrote:
in this thread several people mentioned:

inline ref-counting

what exactly is it? is there something i can read up on anywhere about this, does anyone know?

This is a technique of storing the retain count for an object in the object itself, as opposed to in an external hash table the way that NSObject's default implementation does. Here is a very simple sample implementation of inline ref-counting:

@interface InlineRetainCountedObject : NSObject
{
unsigned int retainCount;
}
@end
@implementation InlineRetainCountedObject

- (unsigned int)retainCount;
{
return retainCount + 1;
}

- (id)retain;
{
retainCount++;
return self;
}

- (void)release;
{
if (retainCount == 0)
[self dealloc];
else
retainCount--;
}
@end

Please note that this is NOT thread-safe. If you might retain/release an object from multiple threads you need to use locking around modifications to the retain count. If you want ObjectAlloc or OmniObjectMeter to work correctly on these types of objects you also need to use the foundation NSRecordAllocationEvent() function when modifying the retain count.

For a more complicated example of an implementation that does handle those things, see the implementation of OFObject in OmniFoundation.

Hope this helps,
- Greg
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Speed Traps (From: Ben Dougall <email@hidden>)

  • Prev by Date: Undo menu not enabling with NSMovieView?
  • Next by Date: Re: try / finally
  • Previous by thread: Re: Speed Traps
  • Next by thread: Undo menu not enabling with NSMovieView?
  • Index(es):
    • Date
    • Thread