Bug 226178 - Add support for better "try-lock" pattern for Locker<Lock>
Summary: Add support for better "try-lock" pattern for Locker<Lock>
Status: ASSIGNED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-05-24 08:59 PDT by Chris Dumez
Modified: 2021-05-31 09:00 PDT (History)
18 users (show)

See Also:


Attachments
WIP Patch (2.51 KB, patch)
2021-05-24 09:13 PDT, Chris Dumez
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
WIP Patch (2.69 KB, patch)
2021-05-24 09:19 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
WIP Patch (more complete) (22.33 KB, patch)
2021-05-24 09:33 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
WIP Patch (more complete) (21.49 KB, patch)
2021-05-24 09:39 PDT, Chris Dumez
ews-feeder: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 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.
```
Comment 1 Chris Dumez 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.
Comment 2 Chris Dumez 2021-05-24 09:19:23 PDT
Created attachment 429537 [details]
WIP Patch
Comment 3 Chris Dumez 2021-05-24 09:33:31 PDT
Created attachment 429540 [details]
WIP Patch (more complete)
Comment 4 Chris Dumez 2021-05-24 09:39:53 PDT
Created attachment 429542 [details]
WIP Patch (more complete)
Comment 5 Chris Dumez 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 :/
Comment 6 Chris Dumez 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..
Comment 7 Radar WebKit Bug Importer 2021-05-31 09:00:20 PDT
<rdar://problem/78689398>