mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Remove AutoClosable implementation of PlayerCommandQueue
PiperOrigin-RevId: 370875532
This commit is contained in:
parent
b336df3ed3
commit
b6f4fbb7dc
1 changed files with 1 additions and 20 deletions
|
|
@ -39,7 +39,7 @@ import java.util.List;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
/** Manages the queue of player actions and handles running them one by one. */
|
/** Manages the queue of player actions and handles running them one by one. */
|
||||||
/* package */ class PlayerCommandQueue implements AutoCloseable {
|
/* package */ class PlayerCommandQueue {
|
||||||
|
|
||||||
private static final String TAG = "PlayerCommandQueue";
|
private static final String TAG = "PlayerCommandQueue";
|
||||||
private static final boolean DEBUG = false;
|
private static final boolean DEBUG = false;
|
||||||
|
|
@ -141,9 +141,6 @@ import java.util.concurrent.Callable;
|
||||||
@GuardedBy("lock")
|
@GuardedBy("lock")
|
||||||
private final Deque<PlayerCommand> pendingPlayerCommandQueue;
|
private final Deque<PlayerCommand> pendingPlayerCommandQueue;
|
||||||
|
|
||||||
@GuardedBy("lock")
|
|
||||||
private boolean closed;
|
|
||||||
|
|
||||||
// Should be only used on the handler.
|
// Should be only used on the handler.
|
||||||
@Nullable private AsyncPlayerCommandResult pendingAsyncPlayerCommandResult;
|
@Nullable private AsyncPlayerCommandResult pendingAsyncPlayerCommandResult;
|
||||||
|
|
||||||
|
|
@ -154,17 +151,6 @@ import java.util.concurrent.Callable;
|
||||||
pendingPlayerCommandQueue = new ArrayDeque<>();
|
pendingPlayerCommandQueue = new ArrayDeque<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() {
|
|
||||||
synchronized (lock) {
|
|
||||||
if (closed) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
closed = true;
|
|
||||||
}
|
|
||||||
reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
handler.removeCallbacksAndMessages(/* token= */ null);
|
handler.removeCallbacksAndMessages(/* token= */ null);
|
||||||
List<PlayerCommand> queue;
|
List<PlayerCommand> queue;
|
||||||
|
|
@ -187,11 +173,6 @@ import java.util.concurrent.Callable;
|
||||||
@CommandCode int commandCode, Callable<Boolean> command, @Nullable Object tag) {
|
@CommandCode int commandCode, Callable<Boolean> command, @Nullable Object tag) {
|
||||||
SettableFuture<PlayerResult> result = SettableFuture.create();
|
SettableFuture<PlayerResult> result = SettableFuture.create();
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
if (closed) {
|
|
||||||
// OK to set result with lock hold because developers cannot add listener here.
|
|
||||||
result.set(new PlayerResult(PlayerResult.RESULT_ERROR_INVALID_STATE, /* item= */ null));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
PlayerCommand playerCommand = new PlayerCommand(commandCode, command, result, tag);
|
PlayerCommand playerCommand = new PlayerCommand(commandCode, command, result, tag);
|
||||||
result.addListener(
|
result.addListener(
|
||||||
() -> {
|
() -> {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue