-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create a new dealloc queue that is more efficient #931
Conversation
Source/ASRunLoopQueue.mm
Outdated
currentQueue.clear(); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
V1 is untouched except to remove the unused test_drain
and _test_drain
methods. The diff is hard to read in unified view =/
CI is super flaky ……… seems like more fails than passes today. @garrettmoon is it worth like restarting the compy or something? That weird simulator bootstrap error =/ |
NSParameterAssert(objectPtr != NULL); | ||
|
||
// Cast to CFType so we can manipulate retain count manually. | ||
auto cfPtr = (CFTypeRef *)(void *)objectPtr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we automatically get a +1 here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, ARC never touches CFTypeRefs, so the retain count of the object doesn't change anywhere in here. What happens is, we "steal" their +1 and set their pointer to nil. So now they can't see or release the object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we had used (__bridge_retained CFTypeRef)
then ARC would have added a +1.
Source/ASRunLoopQueue.mm
Outdated
_lock.lock(); | ||
auto isFirstEntry = _queue.empty(); | ||
// Push the pointer into our queue and clear their strong ref. | ||
_queue.push_back(*cfPtr); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same from above
131b9a7
to
4c8b759
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice!
The current dealloc queue has a number of issues:
This diff creates a new implementation
ASDeallocQueueV2
that solves these issues and is also a lot easier to reason about. The experimental implementation is triggered by the new flagASExperimentalDeallocQueue
.