Skip to content

Commit

Permalink
Merge pull request #1807 from bryceberger/bryce/push-xqrmpyoxlosq
Browse files Browse the repository at this point in the history
docs: specify ThreadSafeRepository is not Send/Sync without "parallel"
  • Loading branch information
Byron authored Jan 26, 2025
2 parents 6065af5 + d7ddbb7 commit 79cb655
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
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(())
}

0 comments on commit 79cb655

Please sign in to comment.