diff options
author | Jesse Hall <jessehall@google.com> | 2014-07-13 12:47:02 -0700 |
---|---|---|
committer | Jesse Hall <jessehall@google.com> | 2014-07-14 19:29:09 +0000 |
commit | b154c42c39c1499c26d88fff8ca642cd86f91098 (patch) | |
tree | 5c3a083d18167ca736b353ad7877441ae93d6396 /services/surfaceflinger/Barrier.h | |
parent | 24cd98eef88ac93f80c327f8d74f0a1ae0aceee4 (diff) | |
download | frameworks_native-b154c42c39c1499c26d88fff8ca642cd86f91098.zip frameworks_native-b154c42c39c1499c26d88fff8ca642cd86f91098.tar.gz frameworks_native-b154c42c39c1499c26d88fff8ca642cd86f91098.tar.bz2 |
Improve memory coherence management in screenshot code [DO NOT MERGE]
The existing code worked in practice, but wasn't quite correct in
theory and relied on implementation details of other code. It's still
somewhat unusual and subtle, but now is correct-in-theory (I believe)
and a little better documented.
Bug: 16044767
Change-Id: I22b01d6640f0b7beca7cbfc74981795a3218b064
(cherry picked from commit c61576794e75898a829eac52fc524c8e907b4b02)
Diffstat (limited to 'services/surfaceflinger/Barrier.h')
-rw-r--r-- | services/surfaceflinger/Barrier.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/services/surfaceflinger/Barrier.h b/services/surfaceflinger/Barrier.h index 6f8507e..3e9d443 100644 --- a/services/surfaceflinger/Barrier.h +++ b/services/surfaceflinger/Barrier.h @@ -28,15 +28,25 @@ class Barrier public: inline Barrier() : state(CLOSED) { } inline ~Barrier() { } + + // Release any threads waiting at the Barrier. + // Provides release semantics: preceding loads and stores will be visible + // to other threads before they wake up. void open() { Mutex::Autolock _l(lock); state = OPENED; cv.broadcast(); } + + // Reset the Barrier, so wait() will block until open() has been called. void close() { Mutex::Autolock _l(lock); state = CLOSED; } + + // Wait until the Barrier is OPEN. + // Provides acquire semantics: no subsequent loads or stores will occur + // until wait() returns. void wait() const { Mutex::Autolock _l(lock); while (state == CLOSED) { |