use of org.eclipse.scout.rt.platform.job.internal.NamedThreadFactory.ThreadInfo in project scout.rt by eclipse.
the class ThreadNameDecorator method decorate.
@Override
public IUndecorator decorate() throws Exception {
final ThreadInfo threadInfo = ThreadInfo.CURRENT.get();
threadInfo.updateThreadName(IFuture.CURRENT.get().getJobInput().getThreadName(), null);
return new IUndecorator() {
@Override
public void undecorate() {
// Restore to the original thread name.
threadInfo.reset();
}
};
}
use of org.eclipse.scout.rt.platform.job.internal.NamedThreadFactory.ThreadInfo in project scout.rt by eclipse.
the class DevelopmentThreadNameDecorator method decorate.
@Override
public IUndecorator decorate() throws Exception {
final ThreadInfo threadInfo = ThreadInfo.CURRENT.get();
final IFuture<?> future = IFuture.CURRENT.get();
// Update the thread name.
threadInfo.updateThreadName(future.getJobInput().getThreadName(), buildExecutionInfo(future));
// Decorate the thread name upon job state change.
final IRegistrationHandle listenerRegistration = future.addListener(Jobs.newEventFilterBuilder().andMatchEventType(JobEventType.JOB_STATE_CHANGED).andMatchState(JobState.RUNNING, JobState.WAITING_FOR_PERMIT, JobState.WAITING_FOR_BLOCKING_CONDITION).toFilter(), new IJobListener() {
@Override
public void changed(final JobEvent event) {
threadInfo.updateThreadName(future.getJobInput().getThreadName(), buildExecutionInfo(future));
}
});
return new IUndecorator() {
@Override
public void undecorate() {
// Restore to the original thread name.
listenerRegistration.dispose();
threadInfo.reset();
}
};
}
Aggregations