Use read-write locks to protect metadata caches. 
Use read-write locks to protect metadata caches. 

Fixes rdar://18346143.


Swift SVN r21966

slavapestov/swift,tardieu/swift,IngmarStein/swift,gottesmm/swift,bitjammer/swift,xedin/swift,xedin/swift,tinysun212/swift-windows,codestergit/swift,gribozavr/swift,practicalswift/swift,johnno1962d/swift,ben-ng/swift,MukeshKumarS/Swift,zisko/swift,xedin/swift,swiftix/swift.old,rudkx/swift,jmgc/swift,glessard/swift,gribozavr/swift,IngmarStein/swift,sschiau/swift,Jnosh/swift,kstaring/swift,harlanhaskins/swift,Ivacker/swift,slavapestov/swift,emilstahl/swift,ahoppen/swift,deyton/swift,glessard/swift,danielmartin/swift,jckarter/swift,harlanhaskins/swift,apple/swift,IngmarStein/swift,slavapestov/swift,uasys/swift,modocache/swift,aschwaighofer/swift,adrfer/swift,kstaring/swift,jckarter/swift,dreamsxin/swift,russbishop/swift,Jnosh/swift,deyton/swift,OscarSwanros/swift,codestergit/swift,tkremenek/swift,JGiola/swift,gottesmm/swift,tinysun212/swift-windows,glessard/swift,dreamsxin/swift,felix91gr/swift,ben-ng/swift,bitjammer/swift,kentya6/swift,hooman/swift,OscarSwanros/swift,emilstahl/swift,karwa/swift,lorentey/swift,alblue/swift,bitjammer/swift,sdulal/swift,devincoughlin/swift,johnno1962d/swift,calebd/swift,ken0nek/swift,ahoppen/swift,tjw/swift,austinzheng/swift,xedin/swift,nathawes/swift,tardieu/swift,MukeshKumarS/Swift,atrick/swift,calebd/swift,benlangmuir/swift,gmilos/swift,alblue/swift,russbishop/swift,aschwaighofer/swift,austinzheng/swift,russbishop/swift,glessard/swift,swiftix/swift,parkera/swift,ahoppen/swift,hooman/swift,hughbe/swift,gribozavr/swift,KrishMunot/swift,kentya6/swift,shahmishal/swift,jtbandes/swift,MukeshKumarS/Swift,cbrentharris/swift,gmilos/swift,arvedviehweger/swift,amraboelela/swift,hughbe/swift,zisko/swift,Jnosh/swift,dduan/swift,roambotics/swift,kusl/swift,manavgabhawala/swift,amraboelela/swift,gregomni/swift,johnno1962d/swift,xwu/swift,shajrawi/swift,karwa/swift,devincoughlin/swift,frootloops/swift,codestergit/swift,zisko/swift,airspeedswift/swift,slavapestov/swift,shajrawi/swift,shahmishal/swift,cbrentharris/swift,SwiftAndroid/swift,atrick/swift,manavgabhawala/swift,devincoughlin/swift,uasys/swift,gribozavr/swift,practicalswift/swift,djwbrown/swift,kstaring/swift,nathawes/swift,gmilos/swift,aschwaighofer/swift,djwbrown/swift,Ivacker/swift,jopamer/swift,allevato/swift,tkremenek/swift,arvedviehweger/swift,austinzheng/swift,tjw/swift,shahmishal/swift,gottesmm/swift,roambotics/swift,jmgc/swift,mightydeveloper/swift,jckarter/swift,tkremenek/swift,khizkhiz/swift,therealbnut/swift,stephentyrone/swift,hughbe/swift,kperryua/swift,gottesmm/swift,lorentey/swift,natecook1000/swift,jmgc/swift,danielmartin/swift,ben-ng/swift,brentdax/swift,jtbandes/swift,parkera/swift,benlangmuir/swift,sdulal/swift,tinysun212/swift-windows,nathawes/swift,hughbe/swift,xwu/swift,benlangmuir/swift,calebd/swift,arvedviehweger/swift,gottesmm/swift,kentya6/swift,djwbrown/swift,rudkx/swift,uasys/swift,aschwaighofer/swift,kusl/swift,JaSpa/swift,amraboelela/swift,shahmishal/swift,xedin/swift,frootloops/swift,benlangmuir/swift,ben-ng/swift,modocache/swift,rudkx/swift,deyton/swift,milseman/swift,therealbnut/swift,atrick/swift,lorentey/swift,adrfer/swift,bitjammer/swift,MukeshKumarS/Swift,swiftix/swift.old,LeoShimonaka/swift,sdulal/swift,danielmartin/swift,jtbandes/swift,Ivacker/swift,JaSpa/swift,djwbrown/swift,zisko/swift,deyton/swift,hooman/swift,natecook1000/swift,apple/swift,return/swift,OscarSwanros/swift,tardieu/swift,russbishop/swift,russbishop/swift,swiftix/swift,johnno1962d/swift,return/swift,danielmartin/swift,MukeshKumarS/Swift,kstaring/swift,allevato/swift,swiftix/swift.old,hooman/swift,felix91gr/swift,IngmarStein/swift,JaSpa/swift,benlangmuir/swift,swiftix/swift.old,glessard/swift,adrfer/swift,SwiftAndroid/swift,SwiftAndroid/swift,return/swift,JGiola/swift,jopamer/swift,parkera/swift,stephentyrone/swift,brentdax/swift,dduan/swift,swiftix/swift,xwu/swift,devincoughlin/swift,JaSpa/swift,Jnosh/swift,kperryua/swift,austinzheng/swift,manavgabhawala/swift,airspeedswift/swift,karwa/swift,JGiola/swift,harlanhaskins/swift,swiftix/swift.old,karwa/swift,tjw/swift,arvedviehweger/swift,gribozavr/swift,apple/swift,bitjammer/swift,kentya6/swift,ken0nek/swift,tinysun212/swift-windows,karwa/swift,jmgc/swift,cbrentharris/swift,calebd/swift,apple/swift,dduan/swift,swiftix/swift.old,khizkhiz/swift,stephentyrone/swift,modocache/swift,mightydeveloper/swift,jmgc/swift,SwiftAndroid/swift,adrfer/swift,amraboelela/swift,kstaring/swift,jopamer/swift,danielmartin/swift,gregomni/swift,kusl/swift,SwiftAndroid/swift,atrick/swift,felix91gr/swift,xedin/swift,roambotics/swift,bitjammer/swift,shahmishal/swift,atrick/swift,tkremenek/swift,nathawes/swift,adrfer/swift,frootloops/swift,tinysun212/swift-windows,zisko/swift,sdulal/swift,alblue/swift,therealbnut/swift,brentdax/swift,JaSpa/swift,jckarter/swift,slavapestov/swift,stephentyrone/swift,airspeedswift/swift,allevato/swift,JaSpa/swift,manavgabhawala/swift,dduan/swift,xwu/swift,sschiau/swift,IngmarStein/swift,therealbnut/swift,gmilos/swift,SwiftAndroid/swift,MukeshKumarS/Swift,ben-ng/swift,jckarter/swift,uasys/swift,milseman/swift,parkera/swift,KrishMunot/swift,allevato/swift,jckarter/swift,kusl/swift,tardieu/swift,tjw/swift,xedin/swift,jopamer/swift,khizkhiz/swift,kperryua/swift,alblue/swift,shajrawi/swift,mightydeveloper/swift,aschwaighofer/swift,KrishMunot/swift,gribozavr/swift,harlanhaskins/swift,shajrawi/swift,cbrentharris/swift,ken0nek/swift,gregomni/swift,swiftix/swift.old,gregomni/swift,tardieu/swift,frootloops/swift,sdulal/swift,brentdax/swift,jtbandes/swift,aschwaighofer/swift,JGiola/swift,milseman/swift,sschiau/swift,codestergit/swift,aschwaighofer/swift,return/swift,practicalswift/swift,dduan/swift,devincoughlin/swift,alblue/swift,harlanhaskins/swift,huonw/swift,hooman/swift,roambotics/swift,russbishop/swift,Ivacker/swift,milseman/swift,allevato/swift,jckarter/swift,return/swift,CodaFi/swift,huonw/swift,khizkhiz/swift,OscarSwanros/swift,nathawes/swift,codestergit/swift,roambotics/swift,swiftix/swift.old,kusl/swift,manavgabhawala/swift,nathawes/swift,swiftix/swift,tkremenek/swift,Jnosh/swift,OscarSwanros/swift,manavgabhawala/swift,felix91gr/swift,sschiau/swift,CodaFi/swift,deyton/swift,mightydeveloper/swift,frootloops/swift,kusl/swift,slavapestov/swift,amraboelela/swift,jtbandes/swift,emilstahl/swift,calebd/swift,danielmartin/swift,practicalswift/swift,zisko/swift,huonw/swift,OscarSwanros/swift,tjw/swift,stephentyrone/swift,modocache/swift,sschiau/swift,parkera/swift,return/swift,KrishMunot/swift,SwiftAndroid/swift,Ivacker/swift,gregomni/swift,jmgc/swift,OscarSwanros/swift,hughbe/swift,modocache/swift,gmilos/swift,jmgc/swift,deyton/swift,kperryua/swift,natecook1000/swift,tinysun212/swift-windows,tkremenek/swift,apple/swift,CodaFi/swift,airspeedswift/swift,khizkhiz/swift,nathawes/swift,arvedviehweger/swift,KrishMunot/swift,kentya6/swift,rudkx/swift,LeoShimonaka/swift,karwa/swift,cbrentharris/swift,austinzheng/swift,xwu/swift,kperryua/swift,shajrawi/swift,IngmarStein/swift,MukeshKumarS/Swift,lorentey/swift,gmilos/swift,tkremenek/swift,kusl/swift,sdulal/swift,jtbandes/swift,kstaring/swift,huonw/swift,emilstahl/swift,ahoppen/swift,shajrawi/swift,arvedviehweger/swift,danielmartin/swift,Jnosh/swift,ben-ng/swift,jopamer/swift,gottesmm/swift,Ivacker/swift,karwa/swift,parkera/swift,shajrawi/swift,dduan/swift,milseman/swift,deyton/swift,manavgabhawala/swift,sdulal/swift,devincoughlin/swift,kusl/swift,rudkx/swift,roambotics/swift,uasys/swift,xwu/swift,gribozavr/swift,parkera/swift,xedin/swift,hughbe/swift,huonw/swift,felix91gr/swift,JaSpa/swift,practicalswift/swift,JGiola/swift,kstaring/swift,ken0nek/swift,adrfer/swift,KrishMunot/swift,Ivacker/swift,alblue/swift,uasys/swift,shahmishal/swift,LeoShimonaka/swift,devincoughlin/swift,cbrentharris/swift,glessard/swift,tjw/swift,devincoughlin/swift,swiftix/swift,kperryua/swift,apple/swift,kentya6/swift,lorentey/swift,gmilos/swift,calebd/swift,mightydeveloper/swift,jopamer/swift,alblue/swift,zisko/swift,harlanhaskins/swift,johnno1962d/swift,djwbrown/swift,tardieu/swift,LeoShimonaka/swift,mightydeveloper/swift,tinysun212/swift-windows,LeoShimonaka/swift,therealbnut/swift,amraboelela/swift,frootloops/swift,gottesmm/swift,IngmarStein/swift,lorentey/swift,emilstahl/swift,KrishMunot/swift,emilstahl/swift,therealbnut/swift,practicalswift/swift,allevato/swift,Jnosh/swift,kentya6/swift,rudkx/swift,austinzheng/swift,allevato/swift,ahoppen/swift,shahmishal/swift,khizkhiz/swift,natecook1000/swift,sschiau/swift,milseman/swift,practicalswift/swift,kentya6/swift,sdulal/swift,arvedviehweger/swift,khizkhiz/swift,CodaFi/swift,natecook1000/swift,hooman/swift,ben-ng/swift,lorentey/swift,parkera/swift,codestergit/swift,amraboelela/swift,airspeedswift/swift,djwbrown/swift,kperryua/swift,practicalswift/swift,huonw/swift,benlangmuir/swift,frootloops/swift,ken0nek/swift,stephentyrone/swift,ahoppen/swift,jtbandes/swift,codestergit/swift,airspeedswift/swift,tjw/swift,russbishop/swift,jopamer/swift,johnno1962d/swift,airspeedswift/swift,xwu/swift,CodaFi/swift,austinzheng/swift,emilstahl/swift,Ivacker/swift,lorentey/swift,modocache/swift,emilstahl/swift,karwa/swift,sschiau/swift,LeoShimonaka/swift,dduan/swift,shahmishal/swift,ken0nek/swift,sschiau/swift,swiftix/swift,return/swift,adrfer/swift,gribozavr/swift,felix91gr/swift,brentdax/swift,LeoShimonaka/swift,uasys/swift,therealbnut/swift,CodaFi/swift,gregomni/swift,johnno1962d/swift,harlanhaskins/swift,natecook1000/swift,atrick/swift,brentdax/swift,CodaFi/swift,modocache/swift,huonw/swift,stephentyrone/swift,cbrentharris/swift,hughbe/swift,slavapestov/swift,tardieu/swift,LeoShimonaka/swift,cbrentharris/swift,mightydeveloper/swift,calebd/swift,bitjammer/swift,brentdax/swift,mightydeveloper/swift,milseman/swift,JGiola/swift,hooman/swift,swiftix/swift,felix91gr/swift,shajrawi/swift,natecook1000/swift,ken0nek/swift,djwbrown/swift