Skip to content

feat(postgres): add PgAdvisoryLockGuardOwned#3442

Closed
bonsairobo wants to merge 1 commit into
transact-rs:mainfrom
bonsairobo:rc-guard
Closed

feat(postgres): add PgAdvisoryLockGuardOwned#3442
bonsairobo wants to merge 1 commit into
transact-rs:mainfrom
bonsairobo:rc-guard

Conversation

@bonsairobo
Copy link
Copy Markdown

This new lock guard can own an Arc<PgAdvisoryLock> without any lifetime, allowing it to be moved into spawned tasks.

Fixes #3429

This new lock guard can own an `Arc<PgAdvisoryLock>` without any lifetime,
allowing it to be moved into spawned tasks.
@abonander
Copy link
Copy Markdown
Collaborator

@bonsairobo (moving the design discussion here)

Re: #3429 (comment)

Is this an optimization to avoid deeply cloning the AdvisoryLock?

The only thing is the memoization of the release query: https://github.com/launchbadge/sqlx/blob/main/sqlx-postgres/src/advisory_lock.rs#L40

Which isn't strictly necessary I suppose. I was trying to amortize the allocation but at the end of the day it's going to be copied into the connection's buffer anyway.

I'm not against just making the guard not borrow the lock anymore, but it'd be a breaking change to remove the lifetime parameter so it would have to wait for 0.9.0 if we went that route.

@bonsairobo
Copy link
Copy Markdown
Author

I'm not against just making the guard not borrow the lock anymore, but it'd be a breaking change to remove the lifetime parameter so it would have to wait for 0.9.0 if we went that route.

That would be my preference. I'm OK to wait for a release.

@abonander
Copy link
Copy Markdown
Collaborator

If you'd like to make those changes then, I'll tag this as Breaking.

@bonsairobo
Copy link
Copy Markdown
Author

Superseded by #3495

@bonsairobo bonsairobo closed this Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AdvisoryLockGuard without lifetime

2 participants