Skip to content
Commit 288dc8fe authored by Winson's avatar Winson
Browse files

Throttle package session async write requests

Previously, async writes were posted to a Handler but not throttled,
so it was possible to do redundant writes when the latest state had
already been saved.

To avoid that, a counter is stored that serves as a request ID that
can be checked against to see if the latest state has already been
saved, skipping the write request if it has.

This is preferred to calling Handler#hasCallbacks or
Handler#removeCallbacks because those will lock the Handler. And taking
the lock twice is perhaps worse than locking once to schedule a no-op
Runnable, although this was not benchmarked.

This also introduces a retry mechanism in case the write fails.

Bug: 168086110

Test: atest PackageSessionTests
Test: atest RequestThrottleTest

Change-Id: I604dc433c77cf1d9d743c8437674576ad087d62c
parent 8d3b1656
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment