Add ref qualifier to DataMutex for more safety
Categories
(Core :: XPCOM, enhancement)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox66 | --- | fixed |
People
(Reporter: jrmuizel, Assigned: jrmuizel)
Details
Attachments
(1 file)
We lose some sugar but gain some safety. This seems like the right trade. If people want sugar they should use Rust.
| Assignee | ||
Comment 1•7 years ago
|
||
We lose some sugar but gain some safety. This seems like the right
trade. If people want sugar they should use Rust.
Comment 3•7 years ago
|
||
| bugherder | ||
Updated•7 years ago
|
| Assignee | ||
Comment 5•6 years ago
|
||
I've actually forgotten. Perhaps the lock can be dropped too early in some situations. I guess I should've written a better commit message. Maybe Nathan remembers.
Comment 6•6 years ago
|
||
I think the concern is T& x = mMember.Lock().ref(); or similar doesn't actually hold the lock as long as you would like. I know there are rules about const references extending lifetimes of temporaries (I can't find the standardese for them right now), but I don't think they would apply in this case (even if x was const T&).
Comment 7•6 years ago
|
||
I was more thinking about operator-> which was also changed by the attached patch to disallow writing something like:
mDataMutex.Lock()->DoSomething()
which is not very convenient. The similar class boost::synchronized_value allows this, e.g.
Maybe the deletions of operator-> (and maybe also operator*) can be removed again?
Description
•