Implement Sync for QCell, LCell and LCellOwner, and Send for TCell. #4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements Sync and Send for a few types that currently don't implement these traits, but I believe it is safe for these types to implement these traits (with the appropriate bounds on T). The justification for why it's sound is written as comments in the code.
It's not terribly useful for these types to implement these traits, since you almost never use these types in a multithreaded context. However, these cell types are a kind of fundamental building block and it's very hard to imagine all the situations in which they may be used. Perhaps some application could work in phases, building a datastructure full of
LCell
s in a single-threaded phase then reading it concurrently in a multi-threaded phase. Maybe someone wants to put aQCellOwner
orLCellOwner
into aMutex
orRwLock
. It's unlikely, but if it's safe, why not allow it?Disclaimer: Please don't just click "accept" without convincing yourself that these trait implementations are indeed sound. I believe they are, and I wrote my reasoning in the comments in the code. But I'm not an expert in these things. I could be wrong.