mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1062661 - Part 1: Fix ResourceQueue::Evict so that it tries to remove enough data to get us under the threshold. r=kinetik
This commit is contained in:
parent
a5e21ac675
commit
35792c7281
@ -102,20 +102,22 @@ public:
|
||||
Push(new ResourceItem(aData, aLength));
|
||||
}
|
||||
|
||||
// Evict data in queue if the total queue size is greater than
|
||||
// aThreshold past the offset. Returns amount evicted.
|
||||
uint32_t Evict(uint64_t aOffset, uint32_t aThreshold) {
|
||||
// Tries to evict at least aSizeToEvict from the queue up until
|
||||
// aOffset. Returns amount evicted.
|
||||
uint32_t Evict(uint64_t aOffset, uint32_t aSizeToEvict) {
|
||||
uint32_t evicted = 0;
|
||||
while (GetLength() - mOffset > aThreshold) {
|
||||
ResourceItem* item = ResourceAt(0);
|
||||
while (ResourceItem* item = ResourceAt(0)) {
|
||||
if (item->mData.Length() + mOffset > aOffset) {
|
||||
break;
|
||||
}
|
||||
mOffset += item->mData.Length();
|
||||
evicted += item->mData.Length();
|
||||
SBR_DEBUGV("ResourceQueue(%p)::Evict(%llu, %u) removed chunk length=%u",
|
||||
this, aOffset, aThreshold, item->mData.Length());
|
||||
this, aOffset, aSizeToEvict, item->mData.Length());
|
||||
delete PopFront();
|
||||
if (aSizeToEvict && evicted >= aSizeToEvict) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return evicted;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user