From ed5ce2396d50672522f0f9888969ad8f2243208b Mon Sep 17 00:00:00 2001 From: olly Date: Wed, 29 May 2019 19:23:42 +0100 Subject: [PATCH] SimpleCache: Tweak comments related to blocking "Write case, lock not available" was a bit confusing. When the content is not cached and the lock is held, it's neither a read or a write case. It's a "can't do anything" case. When blocking, it may subsequently turn into either a read or a write. PiperOrigin-RevId: 250530722 --- .../exoplayer2/upstream/cache/SimpleCache.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/SimpleCache.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/SimpleCache.java index 38c43bd551..1d4481b5cc 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/SimpleCache.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/SimpleCache.java @@ -390,10 +390,11 @@ public final class SimpleCache implements Cache { if (span != null) { return span; } else { - // Write case, lock not available. We'll be woken up when a locked span is released (if the - // released lock is for the requested key then we'll be able to make progress) or when a - // span is added to the cache (if the span is for the requested key and covers the requested - // position, then we'll become a read and be able to make progress). + // Lock not available. We'll be woken up when a span is added, or when a locked span is + // released. We'll be able to make progress when either: + // 1. A span is added for the requested key that covers the requested position, in which + // case a read can be started. + // 2. The lock for the requested key is released, in which case a write can be started. wait(); } } @@ -415,12 +416,12 @@ public final class SimpleCache implements Cache { CachedContent cachedContent = contentIndex.getOrAdd(key); if (!cachedContent.isLocked()) { - // Write case, lock available. + // Write case. cachedContent.setLocked(true); return span; } - // Write case, lock not available. + // Lock not available. return null; }