mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 04:58:45 +00:00
Limit work that happens in LiveRecipientCache lock.
This commit is contained in:
committed by
Cody Henthorne
parent
7b3897cac6
commit
09b818b048
@@ -113,6 +113,7 @@ public final class LiveRecipientCache {
|
||||
newRecipients.stream().filter(this::isValidForCache).forEach(recipient -> {
|
||||
LiveRecipient live;
|
||||
boolean needsResolve;
|
||||
boolean needsSet = false;
|
||||
|
||||
synchronized (recipients) {
|
||||
live = recipients.get(recipient.getId());
|
||||
@@ -122,13 +123,18 @@ public final class LiveRecipientCache {
|
||||
recipients.put(recipient.getId(), live);
|
||||
needsResolve = recipient.isResolving();
|
||||
} else if (live.get().isResolving() || !recipient.isResolving()) {
|
||||
live.set(recipient);
|
||||
needsSet = true;
|
||||
needsResolve = recipient.isResolving();
|
||||
} else {
|
||||
needsResolve = false;
|
||||
}
|
||||
}
|
||||
|
||||
// This requires taking another lock, so we move it out of the critical section above
|
||||
if (needsSet) {
|
||||
live.set(recipient);
|
||||
}
|
||||
|
||||
if (needsResolve) {
|
||||
LiveRecipient toResolve = live;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user