mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
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
This commit is contained in:
parent
71418f9411
commit
ed5ce2396d
@ -390,10 +390,11 @@ public final class SimpleCache implements Cache {
|
|||||||
if (span != null) {
|
if (span != null) {
|
||||||
return span;
|
return span;
|
||||||
} else {
|
} else {
|
||||||
// Write case, lock not available. We'll be woken up when a locked span is released (if the
|
// Lock not available. We'll be woken up when a span is added, or when a locked span is
|
||||||
// released lock is for the requested key then we'll be able to make progress) or when a
|
// released. We'll be able to make progress when either:
|
||||||
// span is added to the cache (if the span is for the requested key and covers the requested
|
// 1. A span is added for the requested key that covers the requested position, in which
|
||||||
// position, then we'll become a read and be able to make progress).
|
// case a read can be started.
|
||||||
|
// 2. The lock for the requested key is released, in which case a write can be started.
|
||||||
wait();
|
wait();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -415,12 +416,12 @@ public final class SimpleCache implements Cache {
|
|||||||
|
|
||||||
CachedContent cachedContent = contentIndex.getOrAdd(key);
|
CachedContent cachedContent = contentIndex.getOrAdd(key);
|
||||||
if (!cachedContent.isLocked()) {
|
if (!cachedContent.isLocked()) {
|
||||||
// Write case, lock available.
|
// Write case.
|
||||||
cachedContent.setLocked(true);
|
cachedContent.setLocked(true);
|
||||||
return span;
|
return span;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write case, lock not available.
|
// Lock not available.
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user