WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED DUPLICATE of
bug 70698
31020
String::crossThreadString is badly named.
https://bugs.webkit.org/show_bug.cgi?id=31020
Summary
String::crossThreadString is badly named.
David Levin
Reported
2009-11-02 10:36:54 PST
It makes it sound like the returned string may be used on more than one thread. The fix is to rename this to "copy".
Attachments
Proposed fix.
(24.86 KB, patch)
2009-11-02 10:44 PST
,
David Levin
levin
: review-
levin
: commit-queue-
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
David Levin
Comment 1
2009-11-02 10:44:00 PST
Created
attachment 42325
[details]
Proposed fix.
David Levin
Comment 2
2009-11-02 10:46:22 PST
This part is only for the crossThreadString method. One issue: Should the copy method in String not be const anymore? (The const seems to imply that it is threadsafe like the length method but the copy method isn't threadsafe.) There needs to be another patch to change the threadsafeCopy method to something else (which I haven't yet figured out a good name for).
Oliver Hunt
Comment 3
2009-11-04 23:07:49 PST
Comment on
attachment 42325
[details]
Proposed fix. I'm unsure about this name -- it doesn't seem to imply thread safety except by implying that it's a "real" copy, eg. implying that it's slow :-/ --Oliver
Darin Adler
Comment 4
2009-11-05 16:26:03 PST
Comment on
attachment 42325
[details]
Proposed fix. I understand that crossThreadString is a poor name. But copy doesn't seem to be better. Since a StringImpl is immutable it makes little sense to talk about copying a handle to one. I think the name has to say *something* about threading or at least something that mentions the storage or reference count. Maybe createDetachedCopy or deepCopy would be best?
David Levin
Comment 5
2009-11-09 11:12:36 PST
Comment on
attachment 42325
[details]
Proposed fix. Marking r- to move out of review queue per bug comments about a better name being needed. Must go off and brainstorm.
David Levin
Comment 6
2010-02-11 10:43:37 PST
I've brainstormed a lot of potential names below: createForAnotherThread instanceForAnotherThread getInstanceForAnotherThread createInstanceForAnotherThread getReferenceForAnotherThread referenceForAnotherThread createReferenceForAnotherThread createNewInstance createDuplicateInstance Personally, I like createDuplicateInstance because it doesn't imply the slowness of "copy" but yet seemed to indicate that there is a new instance with the same information which is what you need for another thread. Is everyone (who wants to give an opinion) fine with "createDuplicateInstance"?
Dmitry Titov
Comment 7
2010-02-11 11:53:43 PST
createDuplicateInstance sounds good. How about simply "clone"? It is usually the same as 'deepCopy', but hopefully without mandatory slowness.
Darin Adler
Comment 8
2010-02-12 11:14:53 PST
I’d like to help. Could someone briefly review here when code needs to call this function and how it should be used? A quick how-to paragraph. I’m hoping that some of the words in that explanation could provide the inspiration for an even-better name.
David Levin
Comment 9
2010-02-12 11:32:14 PST
(In reply to
comment #8
)
> I’d like to help. > > Could someone briefly review here when code needs to call this function and how > it should be used? A quick how-to paragraph. I’m hoping that some of the words > in that explanation could provide the inspiration for an even-better name.
The method should be called when code wants a string with the same contents for use on another thread. It returns a duplicate of the string that is safe to pass to another thread. It attempts to do this efficiently by only doing a real copy for "small" strings. For other strings, it makes the string switch to a (relatively efficient) threadsafe ref counting mechanism for the underlying buffer. Due to the way this method works, it is not threadsafe (when it does the switch to the threadsafe ref counting mechanism) unlike a read-only copy method would be., so the "const" attribute for the method should probably be removed to make this more clear. (I've been strongly considering this for another patch.)
David Levin
Comment 10
2011-10-23 18:05:49 PDT
This is being cleaned up in 70698. *** This bug has been marked as a duplicate of
bug 70698
***
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