Search in sources :

Example 1 with ContextWeakReference

use of com.oracle.truffle.polyglot.PolyglotContextImpl.ContextWeakReference in project graal by oracle.

the class PolyglotEngineImpl method getOrCreateEngineLoggers.

Object getOrCreateEngineLoggers() {
    Object res = engineLoggers;
    if (res == null) {
        synchronized (this.lock) {
            res = engineLoggers;
            if (res == null) {
                LoggerCache loggerCache = PolyglotLoggers.LoggerCache.newEngineLoggerCache(this);
                loggerCache.setOwner(this);
                res = LANGUAGE.createEngineLoggers(loggerCache);
                if (!logLevels.isEmpty()) {
                    EngineAccessor.LANGUAGE.configureLoggers(this, logLevels, res);
                }
                for (ContextWeakReference contextRef : contexts) {
                    PolyglotContextImpl context = contextRef.get();
                    if (context != null && !context.config.logLevels.isEmpty()) {
                        LANGUAGE.configureLoggers(context, context.config.logLevels, res);
                    }
                }
                engineLoggers = res;
            }
        }
    }
    return res;
}
Also used : LoggerCache(com.oracle.truffle.polyglot.PolyglotLoggers.LoggerCache) ContextWeakReference(com.oracle.truffle.polyglot.PolyglotContextImpl.ContextWeakReference)

Example 2 with ContextWeakReference

use of com.oracle.truffle.polyglot.PolyglotContextImpl.ContextWeakReference in project graal by oracle.

the class PolyglotEngineImpl method workContextReferenceQueue.

private void workContextReferenceQueue() {
    Reference<?> ref;
    while ((ref = contextsReferenceQueue.poll()) != null) {
        ContextWeakReference contextRef = (ContextWeakReference) ref;
        if (!contextRef.removed) {
            contextRef.freeSharing(null);
            contexts.remove(contextRef);
            contextRef.removed = true;
        }
    }
}
Also used : ContextWeakReference(com.oracle.truffle.polyglot.PolyglotContextImpl.ContextWeakReference)

Aggregations

ContextWeakReference (com.oracle.truffle.polyglot.PolyglotContextImpl.ContextWeakReference)2 LoggerCache (com.oracle.truffle.polyglot.PolyglotLoggers.LoggerCache)1