android: LibraryLoader: Annotate fields with @GuardedBy
Readability of this class suffers from (perhaps premature) optimizations to eliminate locks in a few places where the class is used only on a single thread. I believe avoiding these locks does not affect correctness in practice, but explaining and maintaining the proper ways to use these classes becomes more time consuming. In this change I: * Annotated the fields that are indeed guarded by the main lock. * Expanded the explanation of the use of the secondary lock. * Also added a few short-lived synchronized blocks, where an explanation of why it can be avoided is long and brittle. This adds more locking, but I believe it won't affect performance noticeably. * Moved a few unguarded fields above the lock, so that the latter can guard everything 'below'. * Made a few minor corrections in comments, now that I looked at this code a bit longer. Bug: 1154224 Change-Id: I346d358a4b2a465cecdec1881908026e17fef7d6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2602285Reviewed-by:Benoit L <lizeb@chromium.org> Commit-Queue: Egor Pasko <pasko@chromium.org> Cr-Commit-Position: refs/heads/master@{#840645}
Showing
Please register or sign in to comment