Merge pull request #678 from sfackler/fix-send
Make postgres::Client Send again
This commit is contained in:
commit
ecc0acbab6
@ -16,14 +16,14 @@ pub struct Connection {
|
|||||||
runtime: Runtime,
|
runtime: Runtime,
|
||||||
connection: Pin<Box<dyn Stream<Item = Result<AsyncMessage, Error>> + Send>>,
|
connection: Pin<Box<dyn Stream<Item = Result<AsyncMessage, Error>> + Send>>,
|
||||||
notifications: VecDeque<Notification>,
|
notifications: VecDeque<Notification>,
|
||||||
notice_callback: Arc<dyn Fn(DbError)>,
|
notice_callback: Arc<dyn Fn(DbError) + Sync + Send>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Connection {
|
impl Connection {
|
||||||
pub fn new<S, T>(
|
pub fn new<S, T>(
|
||||||
runtime: Runtime,
|
runtime: Runtime,
|
||||||
connection: tokio_postgres::Connection<S, T>,
|
connection: tokio_postgres::Connection<S, T>,
|
||||||
notice_callback: Arc<dyn Fn(DbError)>,
|
notice_callback: Arc<dyn Fn(DbError) + Sync + Send>,
|
||||||
) -> Connection
|
) -> Connection
|
||||||
where
|
where
|
||||||
S: AsyncRead + AsyncWrite + Unpin + 'static + Send,
|
S: AsyncRead + AsyncWrite + Unpin + 'static + Send,
|
||||||
|
@ -499,3 +499,12 @@ fn explicit_close() {
|
|||||||
let client = Client::connect("host=localhost port=5433 user=postgres", NoTls).unwrap();
|
let client = Client::connect("host=localhost port=5433 user=postgres", NoTls).unwrap();
|
||||||
client.close().unwrap();
|
client.close().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn check_send() {
|
||||||
|
fn is_send<T: Send>() {}
|
||||||
|
|
||||||
|
is_send::<Client>();
|
||||||
|
is_send::<Statement>();
|
||||||
|
is_send::<Transaction<'_>>();
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user