Search in sources :

Example 1 with ExecutionType

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();
            }
        }
    }
}
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 ExecutionType

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();
                }
            }
        }
    }
}
Also used : ExecutionType(org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest.ExecutionType) TmfCoalescedEventRequest(org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest) ITmfEventRequest(org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest)

Aggregations

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