-
-
Notifications
You must be signed in to change notification settings - Fork 725
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add retrieveMemberByPrefix * Add event pool configuration * Fix javadoc errors * Rename chunkSyncQueue -> chunkQueue
- Loading branch information
1 parent
6ba908c
commit da82e2d
Showing
19 changed files
with
595 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
src/main/java/net/dv8tion/jda/api/utils/concurrent/Task.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* Copyright 2015-2020 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.dv8tion.jda.api.utils.concurrent; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.function.Consumer; | ||
|
||
/** | ||
* Represents an asynchronous task. | ||
* <br>Note: The underlying task may already be started. | ||
* | ||
* @param <T> | ||
* The result type | ||
*/ | ||
public interface Task<T> | ||
{ | ||
/** | ||
* Whether this task has started. | ||
* | ||
* @return True, if this task has already started. | ||
*/ | ||
boolean isStarted(); | ||
|
||
/** | ||
* Provide a callback for exception handling. | ||
* <br>This is an asynchronous operation. | ||
* | ||
* <p>The error will be logged regardless of your callback, this only exists to handle | ||
* failures for other purposes. | ||
* | ||
* @param callback | ||
* The error callback | ||
* | ||
* @throws IllegalArgumentException | ||
* If null is provided | ||
* | ||
* @return The current Task instance for chaining | ||
*/ | ||
Task<T> onError(@Nonnull Consumer<? super Throwable> callback); | ||
|
||
/** | ||
* Provide a callback for success handling. | ||
* <br>This is an asynchronous operation. | ||
* | ||
* @param callback | ||
* The success callback | ||
* | ||
* @throws IllegalArgumentException | ||
* If null is provided | ||
* | ||
* @return The current Task instance for chaining | ||
*/ | ||
Task<T> onSuccess(@Nonnull Consumer<? super T> callback); | ||
|
||
/** | ||
* Blocks the current thread until the result is ready. | ||
* <br>This will not work on the default JDA event thread because it might depend on other events to be processed, | ||
* which could lead to a deadlock. | ||
* | ||
* @throws UnsupportedOperationException | ||
* If this is called on the default JDA event thread | ||
* @throws java.util.concurrent.CompletionException | ||
* If some exception occurred (such as {@link java.util.concurrent.TimeoutException}). | ||
* @throws java.util.concurrent.CancellationException | ||
* If the request was cancelled | ||
* | ||
* @return The result value | ||
*/ | ||
T get(); | ||
|
||
/** | ||
* Cancels the task and will emit a {@link java.util.concurrent.CancellationException CancellationException}. | ||
*/ | ||
void cancel(); | ||
} |
Oops, something went wrong.