Merge pull request #678 from sfackler/fix-send

Make postgres::Client Send again
This commit is contained in:
Steven Fackler 2020-10-19 20:01:31 -04:00 committed by GitHub
commit ecc0acbab6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -16,14 +16,14 @@ pub struct Connection {
runtime: Runtime,
connection: Pin<Box<dyn Stream<Item = Result<AsyncMessage, Error>> + Send>>,
notifications: VecDeque<Notification>,
notice_callback: Arc<dyn Fn(DbError)>,
notice_callback: Arc<dyn Fn(DbError) + Sync + Send>,
}
impl Connection {
pub fn new<S, T>(
runtime: Runtime,
connection: tokio_postgres::Connection<S, T>,
notice_callback: Arc<dyn Fn(DbError)>,
notice_callback: Arc<dyn Fn(DbError) + Sync + Send>,
) -> Connection
where
S: AsyncRead + AsyncWrite + Unpin + 'static + Send,

View File

@ -499,3 +499,12 @@ fn explicit_close() {
let client = Client::connect("host=localhost port=5433 user=postgres", NoTls).unwrap();
client.close().unwrap();
}
#[test]
fn check_send() {
fn is_send<T: Send>() {}
is_send::<Client>();
is_send::<Statement>();
is_send::<Transaction<'_>>();
}