-
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
Add API for main thread deallocation of classes #599
Conversation
🚫 CI failed with log |
e971a69
to
e46bf7b
Compare
🚫 CI failed with log |
Generated by 🚫 Danger |
🚫 CI failed with log |
Thanks for exploring this and also #598!! This is an important line of investigation for a tricky issue... Caching the results of conformsToProtocol: is really important, and I know you're very knowledgable about caches, so it's exciting to see the LRUCache idea :). Should we just cache this kind of info (like "class X needs main thread deallocation: YES or NO") in an infinitely-sized cache instead of LRU? Can we use a C++ unordered_map, from void * (the singleton pointer of the class itself) to BOOL? |
This PR add's a new API to let classes define if objects of that class need to be deallocated on main. Therefore we create the
ASRequiringMainThreadDeallocating
protocol that classes can conform to.As we add some overhead for checking
conformsToProtocol
as well asASClassRequiresMainThreadDeallocation
is a hot path, I added a generic LRUCache to cache main thread deallocation of classes. The LRUCache in general could be handy in other places too as in comparison to NSURLCache it can also have support for primitive types so it could save us boxing / unboxing cost.It is not ready for merge yet as it needs to be cleanup, but I would like to start a conversation if we would like to go forward with this approach.
TODOs:
ASInternalHelpers
Follow up PR to #598
Addresses #586