use of org.eclipse.osgi.internal.log.OrderedExecutor.OrderedTaskQueue in project rt.equinox.framework by eclipse.
the class OrderedExecutor method addLogListener.
void addLogListener(LogListener listener, LogFilter filter) {
listenersLock.writeLock().lock();
try {
ArrayMap<LogListener, Object[]> listenersCopy = new ArrayMap<>(listeners.getKeys(), listeners.getValues());
Object[] listenerObjects = listenersCopy.get(listener);
if (listenerObjects == null) {
// Only create a task queue for non-SynchronousLogListeners
OrderedTaskQueue taskQueue = (listener instanceof SynchronousLogListener) ? null : executor.createQueue();
listenerObjects = new Object[] { filter, taskQueue };
} else if (filter != listenerObjects[0]) {
// update the filter
listenerObjects[0] = filter;
}
listenersCopy.put(listener, listenerObjects);
recalculateFilters(listenersCopy);
listeners = listenersCopy;
} finally {
listenersLock.writeLock().unlock();
}
}
use of org.eclipse.osgi.internal.log.OrderedExecutor.OrderedTaskQueue in project rt.equinox.framework by eclipse.
the class OrderedExecutor method logPrivileged.
void logPrivileged(Bundle bundle, String name, StackTraceElement stackTraceElement, Object context, LogLevel logLevelEnum, int level, String message, Throwable exception) {
LogEntry logEntry = new ExtendedLogEntryImpl(bundle, name, stackTraceElement, context, logLevelEnum, level, message, exception);
storeEntry(logEntry);
ArrayMap<LogListener, Object[]> listenersCopy;
listenersLock.readLock().lock();
try {
listenersCopy = listeners;
} finally {
listenersLock.readLock().unlock();
}
try {
if (incrementNestedCount() >= MAX_RECURSIONS)
return;
int size = listenersCopy.size();
for (int i = 0; i < size; i++) {
Object[] listenerObjects = listenersCopy.getValue(i);
LogFilter filter = (LogFilter) listenerObjects[0];
if (safeIsLoggable(filter, bundle, name, level)) {
LogListener listener = listenersCopy.getKey(i);
OrderedTaskQueue orderedTaskQueue = (OrderedTaskQueue) listenerObjects[1];
if (orderedTaskQueue != null) {
orderedTaskQueue.execute(new LogTask(logEntry, listener), size);
} else {
// log synchronously
safeLogged(listener, logEntry);
}
}
}
} finally {
decrementNestedCount();
}
}
Aggregations