-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #979 from neon-bindings/kv/unnecessary-send
Relax Send constraints
- Loading branch information
Showing
10 changed files
with
107 additions
and
40 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
//! Wrapper that ensures types are always used from the same thread | ||
//! in debug builds. It is a zero-cost in release builds. | ||
|
||
pub(super) use wrapper::DebugSendWrapper; | ||
|
||
#[cfg(debug_assertions)] | ||
mod wrapper { | ||
use std::ops::Deref; | ||
|
||
#[repr(transparent)] | ||
pub struct DebugSendWrapper<T>(send_wrapper::SendWrapper<T>); | ||
|
||
impl<T> DebugSendWrapper<T> { | ||
pub fn new(value: T) -> Self { | ||
Self(send_wrapper::SendWrapper::new(value)) | ||
} | ||
|
||
pub fn take(self) -> T { | ||
self.0.take() | ||
} | ||
} | ||
|
||
impl<T> Deref for DebugSendWrapper<T> { | ||
type Target = T; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&self.0 | ||
} | ||
} | ||
} | ||
|
||
#[cfg(not(debug_assertions))] | ||
mod wrapper { | ||
use std::ops::Deref; | ||
|
||
#[repr(transparent)] | ||
pub struct DebugSendWrapper<T>(T); | ||
|
||
impl<T> DebugSendWrapper<T> { | ||
pub fn new(value: T) -> Self { | ||
Self(value) | ||
} | ||
|
||
pub fn take(self) -> T { | ||
self.0 | ||
} | ||
} | ||
|
||
impl<T> Deref for DebugSendWrapper<T> { | ||
type Target = T; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&self.0 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters