/** * Defer interrupts for the duration of some task. Once the task is complete, any deferred interrupt will be * delivered to the thread, thus the thread interrupt status should be checked upon return. If the current thread * is not a {@code JBossThread}, the task is simply run as-is. * * @param action the task to run * @param <T> the callable's return type * @return the value returned from the callable * @throws Exception if the action throws an exception */ public static <T> T executeWithInterruptDeferred(final Callable<T> action) throws Exception { final JBossThread thread = currentThread(); if (registerDeferral(thread)) try { return action.call(); } finally { unregisterDeferral(thread); } else { // already deferred return action.call(); } }
public static <T, E extends Exception> void acceptInterruptResumedEx(final ExceptionObjIntConsumer<T, E> consumer, T param1, int param2) throws E { final JBossThread thread = currentThread(); if (unregisterDeferral(thread)) try { consumer.accept(param1, param2); } finally { registerDeferral(thread); } else { // already resumed consumer.accept(param1, param2); } }
public static <T, U, R, E extends Exception> R applyInterruptDeferredEx(final ExceptionBiFunction<T, U, R, E> function, T param1, U param2) throws E { final JBossThread thread = currentThread(); if (registerDeferral(thread)) try { return function.apply(param1, param2); } finally { unregisterDeferral(thread); } else { // already deferred return function.apply(param1, param2); } }
public static <T, E extends Exception> void acceptInterruptResumedEx(final ExceptionObjLongConsumer<T, E> consumer, T param1, long param2) throws E { final JBossThread thread = currentThread(); if (unregisterDeferral(thread)) try { consumer.accept(param1, param2); } finally { registerDeferral(thread); } else { // already resumed consumer.accept(param1, param2); } }
public static <T, U, E extends Exception> void acceptInterruptResumedEx(final ExceptionBiConsumer<T, U, E> consumer, T param1, U param2) throws E { final JBossThread thread = currentThread(); if (unregisterDeferral(thread)) try { consumer.accept(param1, param2); } finally { registerDeferral(thread); } else { // already resumed consumer.accept(param1, param2); } }
public static <T, E extends Exception> void acceptInterruptDeferredEx(final ExceptionObjIntConsumer<T, E> consumer, T param1, int param2) throws E { final JBossThread thread = currentThread(); if (registerDeferral(thread)) try { consumer.accept(param1, param2); } finally { unregisterDeferral(thread); } else { // already deferred consumer.accept(param1, param2); } }
public static <T, U, E extends Exception> void acceptInterruptDeferredEx(final ExceptionBiConsumer<T, U, E> consumer, T param1, U param2) throws E { final JBossThread thread = currentThread(); if (registerDeferral(thread)) try { consumer.accept(param1, param2); } finally { unregisterDeferral(thread); } else { // already deferred consumer.accept(param1, param2); } }
public static <T, U, R, E extends Exception> R applyInterruptResumedEx(final ExceptionBiFunction<T, U, R, E> function, T param1, U param2) throws E { final JBossThread thread = currentThread(); if (unregisterDeferral(thread)) try { return function.apply(param1, param2); } finally { registerDeferral(thread); } else { // already resumed return function.apply(param1, param2); } }
public static <T, E extends Exception> void acceptInterruptDeferredEx(final ExceptionObjLongConsumer<T, E> consumer, T param1, long param2) throws E { final JBossThread thread = currentThread(); if (registerDeferral(thread)) try { consumer.accept(param1, param2); } finally { unregisterDeferral(thread); } else { // already deferred consumer.accept(param1, param2); } }
/** * Defer interrupts for the duration of some task. Once the task is complete, any deferred interrupt will be * delivered to the thread, thus the thread interrupt status should be checked upon return. If the current thread * is not a {@code JBossThread}, the task is simply run as-is. * * @param directExecutor the task executor to use * @param task the task to run */ public static void executeWithInterruptDeferred(final DirectExecutor directExecutor, final Runnable task) { final JBossThread thread = currentThread(); if (registerDeferral(thread)) try { directExecutor.execute(task); } finally { unregisterDeferral(thread); } else { // already deferred directExecutor.execute(task); } }
/** * Defer interrupts for the duration of some task. Once the task is complete, any deferred interrupt will be * delivered to the thread, thus the thread interrupt status should be checked upon return. If the current thread * is not a {@code JBossThread}, the task is simply run as-is. * * @param action the task to run * @param <T> the action's return type * @return the value returned from the callable */ public static <T> T executeWithInterruptDeferred(final PrivilegedAction<T> action) { final JBossThread thread = currentThread(); if (registerDeferral(thread)) try { return action.run(); } finally { unregisterDeferral(thread); } else { // already deferred return action.run(); } }
/** * Defer interrupts for the duration of some task. Once the task is complete, any deferred interrupt will be * delivered to the thread, thus the thread interrupt status should be checked upon return. If the current thread * is not a {@code JBossThread}, the task is simply run as-is. * * @param action the task to run * @param <T> the action's return type * @return the value returned from the callable * @throws Exception if the action throws an exception */ public static <T> T executeWithInterruptDeferred(final PrivilegedExceptionAction<T> action) throws Exception { final JBossThread thread = currentThread(); if (registerDeferral(thread)) try { return action.run(); } finally { unregisterDeferral(thread); } else { // already deferred return action.run(); } }
public static <T, U, E extends Exception> void acceptInterruptDeferredEx(final ExceptionBiConsumer<T, U, E> consumer, T param1, U param2) throws E { final JBossThread thread = currentThread(); if (registerDeferral(thread)) try { consumer.accept(param1, param2); } finally { unregisterDeferral(thread); } else { // already deferred consumer.accept(param1, param2); } }
public static <T, U, R, E extends Exception> R applyInterruptResumedEx(final ExceptionBiFunction<T, U, R, E> function, T param1, U param2) throws E { final JBossThread thread = currentThread(); if (unregisterDeferral(thread)) try { return function.apply(param1, param2); } finally { registerDeferral(thread); } else { // already resumed return function.apply(param1, param2); } }
public static <T, E extends Exception> void acceptInterruptResumedEx(final ExceptionObjLongConsumer<T, E> consumer, T param1, long param2) throws E { final JBossThread thread = currentThread(); if (unregisterDeferral(thread)) try { consumer.accept(param1, param2); } finally { registerDeferral(thread); } else { // already resumed consumer.accept(param1, param2); } }
public static <T, U, E extends Exception> void acceptInterruptResumedEx(final ExceptionBiConsumer<T, U, E> consumer, T param1, U param2) throws E { final JBossThread thread = currentThread(); if (unregisterDeferral(thread)) try { consumer.accept(param1, param2); } finally { registerDeferral(thread); } else { // already resumed consumer.accept(param1, param2); } }
public static <T, E extends Exception> void acceptInterruptDeferredEx(final ExceptionObjIntConsumer<T, E> consumer, T param1, int param2) throws E { final JBossThread thread = currentThread(); if (registerDeferral(thread)) try { consumer.accept(param1, param2); } finally { unregisterDeferral(thread); } else { // already deferred consumer.accept(param1, param2); } }
public static <T, U, R, E extends Exception> R applyInterruptResumedEx(final ExceptionBiFunction<T, U, R, E> function, T param1, U param2) throws E { final JBossThread thread = currentThread(); if (unregisterDeferral(thread)) try { return function.apply(param1, param2); } finally { registerDeferral(thread); } else { // already resumed return function.apply(param1, param2); } }
public static <T, E extends Exception> void acceptInterruptResumedEx(final ExceptionObjLongConsumer<T, E> consumer, T param1, long param2) throws E { final JBossThread thread = currentThread(); if (unregisterDeferral(thread)) try { consumer.accept(param1, param2); } finally { registerDeferral(thread); } else { // already resumed consumer.accept(param1, param2); } }
public static <T, U, E extends Exception> void acceptInterruptResumedEx(final ExceptionBiConsumer<T, U, E> consumer, T param1, U param2) throws E { final JBossThread thread = currentThread(); if (unregisterDeferral(thread)) try { consumer.accept(param1, param2); } finally { registerDeferral(thread); } else { // already resumed consumer.accept(param1, param2); } }