Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add {Atomic, Shared}::try_into_owned #701

Merged
merged 3 commits into from
Jul 20, 2022

Conversation

PatrickNorton
Copy link
Contributor

@PatrickNorton PatrickNorton commented May 23, 2021

Sometimes, I have run into times when I have had an Atomic which I know to be either null or valid, and I want to convert it into an Owned. As far as I can tell, there is no way to do this without converting through a Shared, which comes at the const of an additional atomic load. This pull request also adds the same method to Shared for symmetry.

This pull request adds the following methods:

impl<T: ?Sized + Pointable> Atomic<T> {
	pub unsafe fn try_into_owned(self) -> Option<Owned<T>>;
}

impl<T: ?Sized + Pointable> Shared<'_, T> {
	pub unsafe fn try_into_owned(self) -> Option<Owned<T>>;
}

Copy link
Member

@taiki-e taiki-e left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR and sorry for the late review!

bors r+

bors bot added a commit that referenced this pull request May 28, 2022
701: Add {Atomic, Shared}::try_into_owned r=taiki-e a=PatrickNorton

Sometimes, I have run into times when I have had an `Atomic` which I know to be either null or valid, and I want to convert it into an `Owned`. As far as I can tell, there is no way to do this without converting through a `Shared`, which comes at the const of an additional atomic load. This pull request also adds the same method to `Shared` for symmetry.

This pull request adds the following methods:
```rust
impl<T: ?Sized + Pointable> Owned<T> {
	pub unsafe fn try_into_owned(self) -> Option<Owned<T>>;
}

impl<T: ?Sized + Pointable> Shared<'_, T> {
	pub unsafe fn try_into_owned(self) -> Option<Owned<T>>;
}
```

Co-authored-by: Patrick Norton <[email protected]>
@bors
Copy link
Contributor

bors bot commented May 28, 2022

Canceled.

@taiki-e
Copy link
Member

taiki-e commented May 28, 2022

bors r+

bors bot added a commit that referenced this pull request May 28, 2022
701: Add {Atomic, Shared}::try_into_owned r=taiki-e a=PatrickNorton

Sometimes, I have run into times when I have had an `Atomic` which I know to be either null or valid, and I want to convert it into an `Owned`. As far as I can tell, there is no way to do this without converting through a `Shared`, which comes at the const of an additional atomic load. This pull request also adds the same method to `Shared` for symmetry.

This pull request adds the following methods:
```rust
impl<T: ?Sized + Pointable> Owned<T> {
	pub unsafe fn try_into_owned(self) -> Option<Owned<T>>;
}

impl<T: ?Sized + Pointable> Shared<'_, T> {
	pub unsafe fn try_into_owned(self) -> Option<Owned<T>>;
}
```

Co-authored-by: Patrick Norton <[email protected]>
Co-authored-by: Taiki Endo <[email protected]>
@bors
Copy link
Contributor

bors bot commented May 28, 2022

Timed out.

crossbeam-epoch/src/atomic.rs Outdated Show resolved Hide resolved
crossbeam-epoch/src/atomic.rs Outdated Show resolved Hide resolved
crossbeam-epoch/src/atomic.rs Outdated Show resolved Hide resolved
crossbeam-epoch/src/atomic.rs Outdated Show resolved Hide resolved
crossbeam-epoch/src/atomic.rs Outdated Show resolved Hide resolved
crossbeam-epoch/src/atomic.rs Outdated Show resolved Hide resolved
@taiki-e
Copy link
Member

taiki-e commented Jul 20, 2022

bors r+

@bors
Copy link
Contributor

bors bot commented Jul 20, 2022

Build succeeded:

@bors bors bot merged commit 5657596 into crossbeam-rs:master Jul 20, 2022
bors bot added a commit that referenced this pull request Jul 23, 2022
880: Prepare for the next release r=taiki-e a=taiki-e

- crossbeam-channel 0.5.5 -> 0.5.6
  - Bump the minimum supported Rust version to 1.38. (#877)
- crossbeam-deque 0.8.1 -> 0.8.2
  - Bump the minimum supported Rust version to 1.38. (#877)
- crossbeam-epoch 0.9.9 -> 0.9.10
  - Bump the minimum supported Rust version to 1.38. (#877)
  - Mitigate the risk of segmentation faults in buggy downstream implementations. (#879)
  - Add `{Atomic, Shared}::try_into_owned` (#701)
- crossbeam-queue 0.3.5 -> 0.3.6
  - Bump the minimum supported Rust version to 1.38. (#877)
- crossbeam-utils 0.8.10 -> 0.8.11
  - Bump the minimum supported Rust version to 1.38. (#877)
- crossbeam 0.8.1 -> 0.8.2
  - Bump the minimum supported Rust version to 1.38. (#877)


Co-authored-by: Taiki Endo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants