-
Notifications
You must be signed in to change notification settings - Fork 266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rename Task.blocking to Task.callableInExecutor #292
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,6 @@ | |
*/ | ||
package com.linkedin.parseq; | ||
|
||
import com.linkedin.parseq.EngineBuilder; | ||
import com.linkedin.parseq.internal.ArgumentUtil; | ||
import com.linkedin.parseq.promise.Promise; | ||
import com.linkedin.parseq.promise.Promises; | ||
|
@@ -37,7 +36,7 @@ | |
* To use this class with an engine, register an executor with engine using | ||
* {@link #register(EngineBuilder, java.util.concurrent.Executor)} | ||
* | ||
* @deprecated As of 2.0.0, replaced by {@link Task#blocking(String, Callable, Executor) Task.blocking}. | ||
* @deprecated As of 2.0.0, replaced by {@link Task#callableInExecutor(String, Callable, Executor)}. | ||
* @author Walter Fender ([email protected]) | ||
*/ | ||
@Deprecated | ||
|
@@ -51,15 +50,15 @@ public static void register(EngineBuilder builder, Executor executor) { | |
} | ||
|
||
/** | ||
* @deprecated As of 2.0.0, replaced by {@link Task#blocking(String, Callable, Executor) Task.blocking}. | ||
* @deprecated As of 2.0.0, replaced by {@link Task#callableInExecutor(String, Callable, Executor)}. | ||
*/ | ||
@Deprecated | ||
public AsyncCallableTask(final Callable<R> syncJob) { | ||
this(null, syncJob); | ||
} | ||
|
||
/** | ||
* @deprecated As of 2.0.0, replaced by {@link Task#blocking(String, Callable, Executor) Task.blocking}. | ||
* @deprecated As of 2.0.0, replaced by {@link Task#callableInExecutor(String, Callable, Executor)}. | ||
*/ | ||
@Deprecated | ||
public AsyncCallableTask(final String name, final Callable<R> syncJob) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,6 @@ | |
import java.util.concurrent.Callable; | ||
import java.util.concurrent.CompletionStage; | ||
import java.util.concurrent.Executor; | ||
import java.util.concurrent.ThreadPoolExecutor; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.concurrent.TimeoutException; | ||
import java.util.concurrent.atomic.AtomicBoolean; | ||
|
@@ -1079,7 +1078,7 @@ public static <R> Task<R> flatten(final Task<Task<R>> task) { | |
* Creates a new task that have a value of type {@code Void}. Because the | ||
* returned task returns no value, it is typically used to produce side effects. | ||
* It is not appropriate for long running or blocking actions. If action is | ||
* long running or blocking use {@link #blocking(String, Callable, Executor) blocking} method. | ||
* long running or blocking use {@link #callableInExecutor(String, Callable, Executor)} method. | ||
* | ||
* <blockquote><pre> | ||
* // this task will print "Hello" on standard output | ||
|
@@ -1167,7 +1166,7 @@ public static <T> Task<T> failure(final Throwable failure) { | |
* from the supplied callable. This task is useful when doing basic | ||
* computation that does not require asynchrony. It is not appropriate for | ||
* long running or blocking callables. If callable is long running or blocking | ||
* use {@link #blocking(String, Callable, Executor) blocking} method. | ||
* use {@link #callableInExecutor(String, Callable, Executor)} method. | ||
* | ||
* <blockquote><pre> | ||
* // this task will complete with {@code String} representing current time | ||
|
@@ -1313,7 +1312,7 @@ public static <T> Task<T> fromTry(final Try<? extends T> tried) { | |
* | ||
* This method is not appropriate for long running or blocking callables. | ||
* If callable is long running or blocking use | ||
* {@link #blocking(String, Callable, Executor) blocking} method. | ||
* {@link #callableInExecutor(String, Callable, Executor)} method. | ||
* <p> | ||
* | ||
* @param <T> the type of the return value for this task | ||
|
@@ -1403,10 +1402,10 @@ public static <T> Task<T> async(final Function1<Context, Promise<? extends T>> f | |
* @return a new task that will submit the callable to given executor and complete | ||
* with result returned by that callable | ||
*/ | ||
public static <T> Task<T> blocking(final String name, final Callable<? extends T> callable, final Executor executor) { | ||
public static <T> Task<T> callableInExecutor(final String name, final Callable<? extends T> callable, final Executor executor) { | ||
ArgumentUtil.requireNotNull(callable, "callable"); | ||
ArgumentUtil.requireNotNull(callable, "executor"); | ||
Task<T> blockingTask = async(name, () -> { | ||
Task<T> asyncCallableTask = async(name, () -> { | ||
final SettablePromise<T> promise = Promises.settable(); | ||
executor.execute(() -> { | ||
try { | ||
|
@@ -1417,18 +1416,36 @@ public static <T> Task<T> blocking(final String name, final Callable<? extends T | |
} ); | ||
return promise; | ||
}); | ||
blockingTask.getShallowTraceBuilder().setTaskType(TaskType.BLOCKING.getName()); | ||
return blockingTask; | ||
asyncCallableTask.getShallowTraceBuilder().setTaskType(TaskType.CALLABLE_IN_EXECUTOR.getName()); | ||
return asyncCallableTask; | ||
} | ||
|
||
/** | ||
* Equivalent to {@code callableInExecutor("callableInExecutor", callable, executor)}. | ||
* @see #callableInExecutor(String, Callable, Executor) | ||
*/ | ||
public static <T> Task<T> callableInExecutor(final Callable<? extends T> callable, final Executor executor) { | ||
return callableInExecutor("callableInExecutor: " + _taskDescriptor.getDescription(callable.getClass().getName()), callable, executor); | ||
} | ||
|
||
/** | ||
* Equivalent to {@code blocking("blocking", callable, executor)}. | ||
* @see #blocking(String, Callable, Executor) | ||
* @deprecated please use {@link Task#callableInExecutor(Callable, Executor)} | ||
*/ | ||
@Deprecated | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you add java doc to redirect to new method |
||
public static <T> Task<T> blocking(final Callable<? extends T> callable, final Executor executor) { | ||
return blocking("blocking: " + _taskDescriptor.getDescription(callable.getClass().getName()), callable, executor); | ||
return callableInExecutor("callableInExecutor: " + _taskDescriptor.getDescription(callable.getClass().getName()), callable, executor); | ||
} | ||
|
||
|
||
/** | ||
* @deprecated please use {@link Task#callableInExecutor(String, Callable, Executor)} | ||
*/ | ||
@Deprecated | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment on the replacement to use. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. udpated |
||
public static <T> Task<T> blocking(final String name, final Callable<? extends T> callable, final Executor executor) { | ||
return callableInExecutor(name, callable, executor); | ||
} | ||
|
||
|
||
/** | ||
* Creates a new task that will run given tasks in parallel. Returned task | ||
* will be resolved with results of all tasks as soon as all of them has | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment on the replacement to use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
udpated