Search in sources :

Example 1 with SerializableFunction

use of org.apache.cassandra.distributed.api.IIsolatedExecutor.SerializableFunction in project cassandra by apache.

the class InterceptingExecutorFactory method factory.

<F extends ThreadFactory> F factory(String name, Object extraInfo, ThreadGroup threadGroup, UncaughtExceptionHandler uncaughtExceptionHandler, InterceptibleThreadFactory.MetaFactory<F> factory) {
    if (uncaughtExceptionHandler == null)
        uncaughtExceptionHandler = transferToInstance.apply((SerializableFunction<Supplier<Boolean>, UncaughtExceptionHandler>) (reportUnchecked) -> (thread, throwable) -> {
            if (!(throwable instanceof UncheckedInterruptedException) || reportUnchecked.get())
                JVMStabilityInspector.uncaughtException(thread, throwable);
        }).apply(() -> !isClosed);
    if (threadGroup == null)
        threadGroup = this.threadGroup;
    else if (!this.threadGroup.parentOf(threadGroup))
        throw new IllegalArgumentException();
    Runnable onTermination = transferToInstance.apply((SerializableRunnable) FastThreadLocal::removeAll);
    LocalTime time = transferToInstance.apply((IIsolatedExecutor.SerializableCallable<LocalTime>) SimulatedTime.Global::current).call();
    return factory.create(name, Thread.NORM_PRIORITY, classLoader, uncaughtExceptionHandler, threadGroup, onTermination, time, this, extraInfo);
}
Also used : SerializableFunction(org.apache.cassandra.distributed.api.IIsolatedExecutor.SerializableFunction) LocalTime(org.apache.cassandra.simulator.systems.SimulatedTime.LocalTime) SerializableRunnable(org.apache.cassandra.distributed.api.IIsolatedExecutor.SerializableRunnable) UncheckedInterruptedException(org.apache.cassandra.utils.concurrent.UncheckedInterruptedException)

Aggregations

SerializableFunction (org.apache.cassandra.distributed.api.IIsolatedExecutor.SerializableFunction)1 SerializableRunnable (org.apache.cassandra.distributed.api.IIsolatedExecutor.SerializableRunnable)1 LocalTime (org.apache.cassandra.simulator.systems.SimulatedTime.LocalTime)1 UncheckedInterruptedException (org.apache.cassandra.utils.concurrent.UncheckedInterruptedException)1