@Nonnull public CompletableFuture <Void> run (@Nonnull final IThrowingRunnable <? extends Throwable> aRunnable) { return CompletableFuture.runAsync ( () -> { try { aRunnable.run (); } catch (final Throwable t) { LOGGER.error ("Error running AS4 runner " + aRunnable, t); } }, m_aES); }
private static void _timedSearch (@Nonnull final IThrowingRunnable <IOException> aRunnable, @Nonnull final Query aQuery) throws IOException { _timedSearch ( () -> { aRunnable.run (); return null; }, aQuery); }
@Nonnull public static final JPAExecutionResult <?> doInTransaction (@Nonnull @WillNotClose final EntityManager aEntityMgr, final boolean bAllowNestedTransactions, @Nonnull final IThrowingRunnable <Exception> aRunnable) { return doInTransaction (aEntityMgr, bAllowNestedTransactions, () -> { aRunnable.run (); return null; }); }
m_aAction.run (); break outer;
/** * Run the provided action within a locked section. * * @param aRunnable * Callback to be executed * @return {@link ESuccess#FAILURE} if the index is just closing * @throws IOException * may be thrown by the callback */ @Nonnull public ESuccess writeLockedAtomic (@Nonnull final IThrowingRunnable <IOException> aRunnable) throws IOException { m_aRWLock.writeLock ().lock (); try { if (isClosing ()) { LOGGER.info ("Cannot executed something write locked, because Lucene is shutting down"); return ESuccess.FAILURE; } aRunnable.run (); } finally { m_aRWLock.writeLock ().unlock (); } return ESuccess.SUCCESS; }
/** * Execute a callback with autosave being disabled. Must be called outside a * writeLock, as this method locks itself! * * @param aRunnable * The callback to be executed * @throws EXTYPE * In case of an error * @param <EXTYPE> * Exception type that may be thrown */ default <EXTYPE extends Exception> void performWithoutAutoSaveThrowing (@Nonnull final IThrowingRunnable <EXTYPE> aRunnable) throws EXTYPE { ValueEnforcer.notNull (aRunnable, "Runnable"); beginWithoutAutoSave (); try { aRunnable.run (); } finally { endWithoutAutoSave (); } }