/** * convenience for setting "blocking details" on any task where the current thread is running, * while the passed code is executed; often used from groovy as * * <pre>{@code withBlockingDetails("sleeping 5s") { Thread.sleep(5000); } }</pre> * * If code block is null, the description is set until further notice (not cleareed). */ @SuppressWarnings("rawtypes") public static <T> T withBlockingDetails(String description, Callable<T> code) throws Exception { Task current = current(); if (code == null) { log.warn("legacy invocation of withBlockingDetails with null code block, ignoring"); return null; } if (current instanceof BasicTask) ((BasicTask) current).setBlockingDetails(description); try { return code.call(); } finally { if (current instanceof BasicTask) ((BasicTask) current).setBlockingDetails(null); } }
/** * convenience for setting "blocking details" on any task where the current thread is running; * typically invoked prior to a wait, for transparency to a user; then invoked with 'null' just * after the wait */ public static void setBlockingDetails(String description) { Task current = current(); if (current instanceof BasicTask) ((BasicTask) current).setBlockingDetails(description); }