Skip to content

Commit

Permalink
Merge pull request #678 from sfackler/fix-send
Browse files Browse the repository at this point in the history
Make postgres::Client Send again
  • Loading branch information
sfackler authored Oct 20, 2020
2 parents 49ecba4 + db90323 commit ecc0acb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions postgres/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions postgres/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<'_>>();
}

0 comments on commit ecc0acb

Please sign in to comment.