Changeset 174660 in webkit
- Timestamp:
- Oct 13, 2014 3:30:20 PM (10 years ago)
- Location:
- trunk/Source/WTF
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r174633 r174660 1 2014-10-13 Antti Koivisto <antti@apple.com> 2 3 Add StringCapture helper for thread-safe lambda capture 4 https://bugs.webkit.org/show_bug.cgi?id=137664 5 6 Reviewed by Anders Carlsson. 7 8 There is currently no clean way to capture a String in a thread-safe manner. This will now work: 9 10 StringCapture stringCapture(string); 11 auto lambdaThatRunsInAnotherThread = [stringCapture] { String string = stringCapture.string(); ... } 12 13 This type won't be necessary with C++14 initialized lambda capture: [string = string.isolatedCopy()]. 14 15 * wtf/text/WTFString.h: 16 (WTF::StringCapture::StringCapture): Create isolated copy in copy-constructor. 17 (WTF::StringCapture::string): 18 1 19 2014-10-11 KwangHyuk Kim <hyuki.kim@samsung.com> 2 20 -
trunk/Source/WTF/wtf/text/WTFString.h
r173761 r174660 633 633 private: 634 634 const char* m_characters; 635 }; 636 637 // For thread-safe lambda capture: 638 // StringCapture stringCapture(string); 639 // auto lambdaThatRunsInOtherThread = [stringCapture] { String string = stringCapture.string(); ... } 640 // FIXME: Remove when we can use C++14 initialized lambda capture: [string = string.isolatedCopy()]. 641 class StringCapture { 642 public: 643 explicit StringCapture(const String& string) : m_string(string) { } 644 explicit StringCapture(String&& string) : m_string(string) { } 645 StringCapture(const StringCapture& other) : m_string(other.m_string.isolatedCopy()) { } 646 const String& string() const { return m_string; } 647 String releaseString() { return WTF::move(m_string); } 648 649 private: 650 void operator=(const StringCapture&) = delete; 651 String m_string; 635 652 }; 636 653 … … 665 682 using WTF::reverseFind; 666 683 using WTF::ASCIILiteral; 684 using WTF::StringCapture; 667 685 668 686 #include <wtf/text/AtomicString.h>
Note: See TracChangeset
for help on using the changeset viewer.