/** * Provide a task to be run with a given thread key. * <p> * See also: {@link SubmitterExecutor#execute(Runnable)} * * @param taskKey object key where {@code equals()} will be used to determine execution thread * @param task Task to be executed */ public void execute(Object taskKey, Runnable task) { ArgumentVerifier.assertNotNull(taskKey, "taskKey"); ArgumentVerifier.assertNotNull(task, "task"); getLimiterContainer(taskKey).execute(task); }
/** * Provide a task to be run with a given thread key. * <p> * See also: {@link SubmitterExecutor#execute(Runnable)} * * @param taskKey object key where {@code equals()} will be used to determine execution thread * @param task Task to be executed */ public void execute(Object taskKey, Runnable task) { ArgumentVerifier.assertNotNull(taskKey, "taskKey"); ArgumentVerifier.assertNotNull(task, "task"); getLimiterContainer(taskKey).execute(task); }
/** * Submit a callable to be run with a given thread key. * <p> * See also: {@link SubmitterExecutor#submit(Callable)} * * @param <TT> type of result returned from the future * @param taskKey object key where {@code equals()} will be used to determine execution thread * @param task Callable to be executed * @return Future to represent when the execution has occurred and provide the result from the callable */ public <TT> ListenableFuture<TT> submit(Object taskKey, Callable<TT> task) { ArgumentVerifier.assertNotNull(taskKey, "taskKey"); ArgumentVerifier.assertNotNull(task, "task"); LimiterContainer lc = getLimiterContainer(taskKey); ListenableRunnableFuture<TT> rf = new ListenableFutureTask<>(false, task, lc.limiter); lc.submit(rf); return rf; }
/** * Submit a callable to be run with a given thread key. * <p> * See also: {@link SubmitterExecutor#submit(Callable)} * * @param <TT> type of result returned from the future * @param taskKey object key where {@code equals()} will be used to determine execution thread * @param task Callable to be executed * @return Future to represent when the execution has occurred and provide the result from the callable */ public <TT> ListenableFuture<TT> submit(Object taskKey, Callable<TT> task) { ArgumentVerifier.assertNotNull(taskKey, "taskKey"); ArgumentVerifier.assertNotNull(task, "task"); LimiterContainer lc = getLimiterContainer(taskKey); ListenableRunnableFuture<TT> rf = new ListenableFutureTask<>(false, task, lc.limiter); lc.submit(rf); return rf; }