Package org.infinispan.commons.test
Class BlockHoundHelper
java.lang.Object
org.infinispan.commons.test.BlockHoundHelper
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidallowBlocking(Runnable runnable) static ExecutorReturns an Executor that when supplied a task, will allow it to invoke blocking calls, even if the invoking context was already registered as non blocking.static <V> voidblockingConsume(V consumed) Helper method that "blocks" as dictated by block hound but in actuality does nothing.static booleanReturns true if the current thread at this time requires all invocations to be non blockingstatic voidensureNonBlocking(Runnable runnable) Invokes the provided Runnable in a scope that guarantees that the current thread is not blocked.static <V> VensureNonBlocking(Supplier<V> supplier) Invokes the provided Supplier in a scope that guarantees that the current thread is not blocked.static ExecutorReturns an Executor that when supplied a task, will guarantee that task does not block when invoked.
-
Method Details
-
currentThreadRequiresNonBlocking
public static boolean currentThreadRequiresNonBlocking()Returns true if the current thread at this time requires all invocations to be non blocking -
ensureNonBlocking
Invokes the provided Supplier in a scope that guarantees that the current thread is not blocked. If blocking is found the invoking test will fail. -
ensureNonBlocking
Invokes the provided Runnable in a scope that guarantees that the current thread is not blocked. If blocking is found the invoking test will fail. -
allowBlocking
-
ensureNonBlockingExecutor
Returns an Executor that when supplied a task, will guarantee that task does not block when invoked. If the task does block it will fail the invoking test. -
allowBlockingExecutor
Returns an Executor that when supplied a task, will allow it to invoke blocking calls, even if the invoking context was already registered as non blocking. Useful to mock submission to a blocking executor. -
blockingConsume
public static <V> void blockingConsume(V consumed) Helper method that "blocks" as dictated by block hound but in actuality does nothing. This is useful to detect if the given code is actually be invoked in an method that allows for blocking or not.- Type Parameters:
V- whatever desired type is- Parameters:
consumed- an argument useful for making this method a `Consumer` via method reference
-