Make postgres::Client Send again

Closes #677
This commit is contained in:
Steven Fackler
2020-10-19 19:58:41 -04:00
parent 49ecba4d6d
commit db90323b08
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<'_>>();
}