ASSIGNED226178
Add support for better "try-lock" pattern for Locker<Lock>
https://bugs.webkit.org/show_bug.cgi?id=226178
Summary Add support for better "try-lock" pattern for Locker<Lock>
Chris Dumez
Reported 2021-05-24 08:59:44 PDT
Add support for better "try-lock" pattern for Locker<Lock>. Maybe: ``` Locker locker { DeferLock, m_lock }; if (!locker.tryLock()) return; // Do something. ``` I think it would be nicer than the current: ``` if (!m_lock.tryLock()) return; Locker locker { AdoptLock, m_lock }; // Do something. ```
Attachments
WIP Patch (2.51 KB, patch)
2021-05-24 09:13 PDT, Chris Dumez
ews-feeder: commit-queue-
WIP Patch (2.69 KB, patch)
2021-05-24 09:19 PDT, Chris Dumez
no flags
WIP Patch (more complete) (22.33 KB, patch)
2021-05-24 09:33 PDT, Chris Dumez
no flags
WIP Patch (more complete) (21.49 KB, patch)
2021-05-24 09:39 PDT, Chris Dumez
ews-feeder: commit-queue-
Chris Dumez
Comment 1 2021-05-24 09:13:23 PDT
Created attachment 429536 [details] WIP Patch Very minimal patch for now as EWS didn't like it last time I tried this approach.
Chris Dumez
Comment 2 2021-05-24 09:19:23 PDT
Created attachment 429537 [details] WIP Patch
Chris Dumez
Comment 3 2021-05-24 09:33:31 PDT
Created attachment 429540 [details] WIP Patch (more complete)
Chris Dumez
Comment 4 2021-05-24 09:39:53 PDT
Created attachment 429542 [details] WIP Patch (more complete)
Chris Dumez
Comment 5 2021-05-24 09:59:35 PDT
Comment on attachment 429542 [details] WIP Patch (more complete) View in context: https://bugs.webkit.org/attachment.cgi?id=429542&action=review > Source/WebCore/Modules/speech/SpeechRecognitionCaptureSourceImpl.cpp:88 > + Locker locker { DeferLock, m_dataSourceLock }; ./Modules/speech/SpeechRecognitionCaptureSourceImpl.cpp:109:5: error: writing variable 'm_dataSource' requires holding mutex 'm_dataSourceLock' exclusively [-Werror,-Wthread-safety-analysis] EWS gets this error. I don't see what I am doing wrong here and this works fine locally :/
Chris Dumez
Comment 6 2021-05-24 10:04:23 PDT
Add https://bugs.webkit.org/attachment.cgi?id=429537&action=prettypatch was building fine so the pattern seems to be working, at least in some cases..
Radar WebKit Bug Importer
Comment 7 2021-05-31 09:00:20 PDT
Note You need to log in before you can comment on or make changes to this bug.