Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: specify ThreadSafeRepository is not Send/Sync without "parallel" #1807

Merged
merged 2 commits into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions gix/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ pub struct Reference<'r> {
/// Note that it clones itself so that it is empty, requiring the user to configure each clone separately, specifically
/// and explicitly. This is to have the fastest-possible default configuration available by default, but allow
/// those who experiment with workloads to get speed boosts of 2x or more.
///
/// ### `Send` only with `parallel` feature
///
/// When built with `default-features = false`, this type is **not** `Send`.
/// The minimal feature set to activate `Send` is `features = ["parallel"]`.
pub struct Repository {
/// A ref store with shared ownership (or the equivalent of it).
pub refs: crate::RefStore,
Expand Down Expand Up @@ -182,6 +187,11 @@ pub struct Repository {
/// it's merely meant to be able to exist in a `Sync` context.
///
/// Note that it can also cheaply be cloned, and it will retain references to all contained resources.
///
/// ### `Send` only with `parallel` feature
///
/// When built with `default-features = false`, this type is **not** `Send`.
/// The minimal feature set to activate `Send` is `features = ["parallel"]`.
#[derive(Clone)]
pub struct ThreadSafeRepository {
/// A store for references to point at objects
Expand Down
8 changes: 8 additions & 0 deletions gix/tests/gix/repository/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,11 @@ fn thread_safe_repository_is_sync() -> crate::Result {
f(crate::util::basic_repo()?.into_sync());
Ok(())
}

#[test]
#[cfg(feature = "parallel")]
fn repository_is_send() -> crate::Result {
fn f<T: Send + Clone>(_t: T) {}
f(crate::util::basic_repo()?);
Ok(())
}
Loading