Commit 7d0ec68d by eguven Committed by Oliver Woodman

Put DownloadTasks on hold until preceding conflicting tasks are complete

Tasks conflict if both of them work on the same media and at least one
of them is remove action.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172741795
parent bb3dea51
......@@ -25,4 +25,9 @@ public final class DownloadException extends IOException {
super(message);
}
/** @param cause The cause for the exception. */
public DownloadException(Throwable cause) {
super(cause);
}
}
......@@ -16,8 +16,8 @@
package com.google.android.exoplayer2.util;
/**
* A condition variable whose {@link #open()} and {@link #close()} methods return whether they
* resulted in a change of state.
* An interruptible condition variable whose {@link #open()} and {@link #close()} methods return
* whether they resulted in a change of state.
*/
public final class ConditionVariable {
......@@ -59,4 +59,21 @@ public final class ConditionVariable {
}
}
/**
* Blocks until the condition is opened or until timeout milliseconds have passed.
*
* @param timeout The maximum time to wait in milliseconds.
* @return true If the condition was opened, false if the call returns because of the timeout.
* @throws InterruptedException If the thread is interrupted.
*/
public synchronized boolean block(int timeout) throws InterruptedException {
long now = System.currentTimeMillis();
long end = now + timeout;
while (!isOpen && now < end) {
wait(end - now);
now = System.currentTimeMillis();
}
return isOpen;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment