private openRepository ( Key location, bool mustExist ) : |
||
location | Key | |
mustExist | bool | |
return |
private Repository openRepository(Key location, bool mustExist)
{
WeakReference<Repository> @ref = cacheMap.GetValue(location);
Repository db = @ref != null ? @ref.get() : null;
if (db == null)
{
lock (lockFor(location))
{
@ref = cacheMap.GetValue(location);
db = @ref != null ? @ref.get() : null;
if (db == null)
{
db = location.open(mustExist);
@ref = new WeakReference<Repository>(db);
cacheMap.AddOrReplace(location, @ref);
}
}
}
db.IncrementOpen();
return db;
}