Skip to content

Commit

Permalink
Merge cb5497d into 2f7300e
Browse files Browse the repository at this point in the history
  • Loading branch information
fdodino committed Jul 18, 2019
2 parents 2f7300e + cb5497d commit 5036d5e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class WollokGlobalScopeProvider extends DefaultGlobalScopeProvider {
@Inject
WollokImportedNamespaceAwareLocalScopeProvider localScopeProvider

override synchronized IScope getScope(IScope parent, Resource context, boolean ignoreCase, EClass type,
override IScope getScope(IScope parent, Resource context, boolean ignoreCase, EClass type,
Predicate<IEObjectDescription> filter) {
var explicitImportedObjects = context.importedObjects
if (filter !== null)
Expand All @@ -60,7 +60,7 @@ class WollokGlobalScopeProvider extends DefaultGlobalScopeProvider {
/**
* Loads all imported elements from a context
*/
def synchronized importedObjects(Resource context) {
def importedObjects(Resource context) {
if (context === null || context.contents === null) {
return #{}
}
Expand All @@ -72,7 +72,7 @@ class WollokGlobalScopeProvider extends DefaultGlobalScopeProvider {
* Calculates the explicit imports using the import construction and all the objects that are accessed through a FQN
* It caches the values to modifications
*/
def synchronized calculateImports(Resource context) {
def calculateImports(Resource context) {
val importsCache = new OnChangeEvictingCache().getOrCreate(context)
var result = importsCache.get("ImportsInResource")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,30 @@ class MapBasedWollokGlobalScopeCache implements WollokGlobalScopeCache {

val cache = new LRUMap(20)

override synchronized get(URI uri, Set<String> imports, Function0<Iterable<IEObjectDescription>> ifAbsentBlock) {
override get(URI uri, Set<String> imports, Function0<Iterable<IEObjectDescription>> ifAbsentBlock) {
val uriString = uri.toString
var cacheContent = cache.get(uriString) as MapBasedCacheContent
if (cacheContent === null || cacheContent.mismatch(imports)) {
cacheContent = new MapBasedCacheContent(uri, imports, ifAbsentBlock.apply)
cache.put(uriString, cacheContent)
synchronized (this) {
cache.put(uriString, cacheContent)
}
}
cacheContent.result
}

override synchronized invalidateDependencies(URI uri) {
override invalidateDependencies(URI uri) {
val Set<String> uris = cache.keySet

uris.clone.filter [ String uriDependency |
(cache.get(uriDependency) as MapBasedCacheContent).hasDependencyWith(uri)
].forEach [
cache.remove(it)
]
cache.remove(uri.toString)
val urisCloned = uris.clone

synchronized (this) {
urisCloned.filter [ String uriDependency |
(cache.get(uriDependency) as MapBasedCacheContent).hasDependencyWith(uri)
].forEach [
cache.remove(it)
]
cache.remove(uri.toString)
}
}
}

Expand Down

0 comments on commit 5036d5e

Please sign in to comment.