Search in sources :

Example 1 with TmfEventThread

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();
            }
        }
    }
}
Also used : ExecutionType(org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest.ExecutionType) TmfEventThread(org.eclipse.tracecompass.internal.tmf.core.component.TmfEventThread) FlowScopeLog(org.eclipse.tracecompass.common.core.log.TraceCompassLogUtils.FlowScopeLog) FlowScopeLogBuilder(org.eclipse.tracecompass.common.core.log.TraceCompassLogUtils.FlowScopeLogBuilder)

Example 2 with TmfEventThread

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);
}
Also used : TmfEventThread(org.eclipse.tracecompass.internal.tmf.core.component.TmfEventThread)

Aggregations

TmfEventThread (org.eclipse.tracecompass.internal.tmf.core.component.TmfEventThread)2 FlowScopeLog (org.eclipse.tracecompass.common.core.log.TraceCompassLogUtils.FlowScopeLog)1 FlowScopeLogBuilder (org.eclipse.tracecompass.common.core.log.TraceCompassLogUtils.FlowScopeLogBuilder)1 ExecutionType (org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest.ExecutionType)1