use of org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest.ExecutionType in project tracecompass by tracecompass.
the class TmfRequestExecutor method execute.
@Override
public synchronized void execute(final Runnable command) {
// We are expecting MyEventThread:s
if (!(command instanceof TmfEventThread)) {
// $NON-NLS-1$ //$NON-NLS-2$
TraceCompassLogUtils.traceInstant(LOGGER, Level.WARNING, "RequestExecutor:NotATmfEventThread", "cmd", command.toString());
return;
}
try (FlowScopeLog scope = new FlowScopeLogBuilder(LOGGER, Level.FINE, "RequestExecutor:CreatingThread").setCategory(LOG_CATEGORY).build()) {
// $NON-NLS-1$
// Wrap the thread in a MyThread
TmfEventThread thread = (TmfEventThread) command;
TmfEventThread wrapper = new TmfEventThread(thread) {
@Override
public void run() {
try (FlowScopeLog log = new FlowScopeLogBuilder(LOGGER, Level.FINE, "RequestExecutor:RunningRequest", "thread", thread.getThread(), "execution type", thread.getExecType()).setParentScope(scope).build()) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
thread.run();
} finally {
scheduleNext();
}
}
};
// Add the thread to the appropriate queue
ExecutionType priority = thread.getExecType();
if (priority == ExecutionType.FOREGROUND) {
if (!fForegroundTasks.offer(wrapper)) {
wrapper.cancel();
}
} else {
if (!fBackgroundTasks.offer(wrapper)) {
wrapper.cancel();
}
}
}
}
use of org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest.ExecutionType in project tracecompass by tracecompass.
the class TmfEventProvider method fireRequest.
private void fireRequest(boolean isTimeout) {
synchronized (fLock) {
if (fRequestPendingCounter > 0) {
return;
}
if (!fPendingCoalescedRequests.isEmpty()) {
Iterator<TmfCoalescedEventRequest> iter = fPendingCoalescedRequests.iterator();
while (iter.hasNext()) {
ExecutionType type = (isTimeout ? ExecutionType.BACKGROUND : ExecutionType.FOREGROUND);
ITmfEventRequest request = iter.next();
if (type == request.getExecType()) {
queueRequest(request);
iter.remove();
}
}
}
}
}
Aggregations