use of org.eclipse.tracecompass.internal.tmf.core.component.TmfEventThread 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.internal.tmf.core.component.TmfEventThread in project tracecompass by tracecompass.
the class TmfEventProvider method queueRequest.
// ------------------------------------------------------------------------
// Request processing
// ------------------------------------------------------------------------
/**
* Queue a request.
*
* @param request
* The data request
*/
protected void queueRequest(final ITmfEventRequest request) {
if (fExecutor.isShutdown()) {
request.cancel();
return;
}
TmfEventThread thread = new TmfEventThread(this, request);
if (TmfCoreTracer.isRequestTraced()) {
// $NON-NLS-1$
TmfCoreTracer.traceRequest(request.getRequestId(), "QUEUED");
}
fExecutor.execute(thread);
}
Aggregations