Created
May 14, 2013 10:59
-
-
Save OdNairy/5575157 to your computer and use it in GitHub Desktop.
Реализация retain
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (id)retain | |
__attribute__((aligned(16))) | |
{ | |
if (OBJC_IS_TAGGED_PTR(self)) return self; | |
SideTable *table = SideTable::tableForPointer(self); | |
if (OSSpinLockTry(&table->slock)) { | |
table->refcnts[DISGUISE(self)] += 2; | |
OSSpinLockUnlock(&table->slock); | |
return self; | |
} | |
return _objc_rootRetain_slow(self); | |
} | |
id | |
_objc_rootRetain_slow(id obj) | |
{ | |
SideTable *table = SideTable::tableForPointer(obj); | |
OSSpinLockLock(&table->slock); | |
table->refcnts[DISGUISE(obj)] += 2; | |
OSSpinLockUnlock(&table->slock); | |
return obj; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment