WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
122946
Main thread tasks in ThreadableBlobRegistry should use std::unique_ptr
https://bugs.webkit.org/show_bug.cgi?id=122946
Summary
Main thread tasks in ThreadableBlobRegistry should use std::unique_ptr
Zan Dobersek
Reported
2013-10-17 00:45:45 PDT
Main thread tasks in ThreadableBlobRegistry should use std::unique_ptr
Attachments
Patch
(4.26 KB, patch)
2013-10-17 00:56 PDT
,
Zan Dobersek
no flags
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Zan Dobersek
Comment 1
2013-10-17 00:56:37 PDT
Created
attachment 214429
[details]
Patch
Darin Adler
Comment 2
2013-11-02 14:17:35 PDT
Comment on
attachment 214429
[details]
Patch Every time we have a new rather than a make_unique, it makes it hard to be sure we got the object lifetime right. It would be nicer to use the lambda form of callOnMainThread so we could pass the unique_ptr through rather than having to pass it through as a void*.
Zan Dobersek
Comment 3
2013-11-04 09:37:42 PST
Lambda could be used here if wrapped inside std::bind() with a naked pointer to the BlobRegistryContext object bound as the first argument to the lambda function, where the pointer would then be put under a std::unique_ptr. Binding std::unique_ptr as the first argument to the lambda function doesn't work since storing the std::bind() product inside a std::function requires that product to be copy-constructible, but this falters since std::unique_ptr is not copyable. So, this works, and I have a patch ready if it's preferable: callOnMainThread(std::bind([](BlobRegistryContext* contextPtr) { std::unique_ptr<BlobRegistryContext> context(contextPtr); blobRegistry().registerBlobURL(context->url, std::move(context->blobData)); }, new BlobRegistryContext(url, std::move(blobData))));
Anders Carlsson
Comment 4
2013-11-04 10:58:20 PST
(In reply to
comment #3
)
> Lambda could be used here if wrapped inside std::bind() with a naked pointer to the BlobRegistryContext object bound as the first argument to the lambda function, where the pointer would then be put under a std::unique_ptr. > > Binding std::unique_ptr as the first argument to the lambda function doesn't work since storing the std::bind() product inside a std::function requires that product to be copy-constructible, but this falters since std::unique_ptr is not copyable. > > So, this works, and I have a patch ready if it's preferable: > > callOnMainThread(std::bind([](BlobRegistryContext* contextPtr) { > std::unique_ptr<BlobRegistryContext> context(contextPtr); > blobRegistry().registerBlobURL(context->url, std::move(context->blobData)); > }, new BlobRegistryContext(url, std::move(blobData))));
Let’s hold off on making such a change. I’m working on an experiment that will let you create a lambda and do a “cross-thread copy” of all the required parameters.
Zan Dobersek
Comment 5
2013-11-05 00:06:46 PST
OK, I'll land the original patch.
Zan Dobersek
Comment 6
2013-11-05 02:47:00 PST
Comment on
attachment 214429
[details]
Patch Clearing flags on attachment: 214429 Committed
r158661
: <
http://trac.webkit.org/changeset/158661
>
Zan Dobersek
Comment 7
2013-11-05 02:47:06 PST
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug