Gate access to cached instances. (#3766)
Gate access to cached instances. (#3766)

* Gate access to cached instances.

This is causing an issue in #3728. Hopefully this will fix it, but no
repro is available yet to test. There's still an underlying race
condition where a `creationBlock` could be called twice for a component
that is supposed to cache the instance returned, but that should be
addressed in a follow up PR.

* Review feedback.

firebase/firebase-ios-sdk,firebase/firebase-ios-sdk,firebase/firebase-ios-sdk,firebase/firebase-ios-sdk,firebase/firebase-ios-sdk,firebase/firebase-ios-sdk,firebase/firebase-ios-sdk