Skip to content

What happen when a pool is cloned? #917

Answered by mehcode
sylvain101010 asked this question in Q&A
Discussion options

You must be logged in to vote

Refer to:

pub struct Pool<DB: Database>(pub(crate) Arc<SharedPool<DB>>);

The actual connection pool is a private SharedPool type. The public Pool type wraps that type in an Arc.

In effect, all that pool.clone() does is clone the reference, thus giving you more places you can reference the pool from.

It's fully intended to be cloned all over the place and given to different threads, etc.

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by abonander
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants