Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
* make `Send` docs more prominent
* add test
  • Loading branch information
Byron committed Jan 26, 2025
1 parent 687322b commit d7ddbb7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
10 changes: 7 additions & 3 deletions gix/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ pub struct Reference<'r> {
/// 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.
///
/// Note: when built with `default-features = false`, this type is **not** `Send`.
/// ### `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).
Expand Down Expand Up @@ -186,8 +188,10 @@ pub struct Repository {
///
/// Note that it can also cheaply be cloned, and it will retain references to all contained resources.
///
/// Note: when built with `default-features = false`, this type is **not** `Send` or `Sync`.
/// The minimal feature set to activate `Send + Sync` is `features = ["parallel"]`.
/// ### `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 d7ddbb7

Please sign in to comment.