aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkRWBuffer.h
diff options
context:
space:
mode:
authorGravatar scroggo <scroggo@google.com>2016-04-14 11:40:48 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-04-14 11:40:48 -0700
commitd06920a29fe11c68bde2b93948ec99f277bb8459 (patch)
treeebe20f9cd4b63247d52fc555ca620accec5eabdd /include/core/SkRWBuffer.h
parentd5f2e2e7429b643943d2f8a532c65e2498223b5b (diff)
Fixes for SkRWBuffer
Do not call SkBufferHead::validate in SkROBuffer's destructor, which may be called in a separate thread from SkRWBuffer::append. validate() reads SkBufferBlock::fUsed, and append() writes to it, resulting in a data race. Update some comments to be more clear about how it is safe to use these classes across threads. Test the readers in separate threads. In addition, make sure it is safe to create a reader even when no data has been appended. Add tests for this case. Mark a parameter to SkBufferHead::validate() as const, reflecting its use. BUG=chromium:601578 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1871953002 Review URL: https://codereview.chromium.org/1871953002
Diffstat (limited to 'include/core/SkRWBuffer.h')
-rw-r--r--include/core/SkRWBuffer.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/include/core/SkRWBuffer.h b/include/core/SkRWBuffer.h
index d054e0a5fd..ff807766d0 100644
--- a/include/core/SkRWBuffer.h
+++ b/include/core/SkRWBuffer.h
@@ -67,8 +67,9 @@ private:
/**
* Accumulates bytes of memory that are "appended" to it, growing internal storage as needed.
- * The growth is done such that at any time, a RBuffer or StreamAsset can be snapped off, which
- * can see the previously stored bytes, but which will be unaware of any future writes.
+ * The growth is done such that at any time in the writer's thread, an RBuffer or StreamAsset
+ * can be snapped off (and safely passed to another thread). The RBuffer/StreamAsset snapshot
+ * can see the previously stored bytes, but will be unaware of any future writes.
*/
class SK_API SkRWBuffer {
public: