# HG changeset patch # User Raphaël Gomès # Date 2023-10-26 13:26:19 # Node ID ca81cd96000ad174c47b8f20da9794126cb4c00f # Parent 3551f2a1c9636385339184905438ce754036722a rust-index: add Sync bound to all relevant mmap-derived values All readonly mmaps are Sync as far as Rust is concerned. Integrity of the mmap'ed file is a concern separate to Rust's memory model, since it requires out-of-program handling via locks, etc. This will help when we start sharing the Rust Index with Python. diff --git a/rust/hg-core/src/revlog/index.rs b/rust/hg-core/src/revlog/index.rs --- a/rust/hg-core/src/revlog/index.rs +++ b/rust/hg-core/src/revlog/index.rs @@ -85,7 +85,7 @@ impl IndexHeader { /// happened. This makes it transparent for the callers. struct IndexData { /// Immutable bytes, most likely taken from disk - bytes: Box + Send>, + bytes: Box + Send + Sync>, /// Used when stripping index contents, keeps track of the start of the /// first stripped revision, which is used to give a slice of the /// `bytes` field. @@ -95,7 +95,7 @@ struct IndexData { } impl IndexData { - pub fn new(bytes: Box + Send>) -> Self { + pub fn new(bytes: Box + Send + Sync>) -> Self { Self { bytes, truncation: None, @@ -328,7 +328,7 @@ impl Index { /// Create an index from bytes. /// Calculate the start of each entry when is_inline is true. pub fn new( - bytes: Box + Send>, + bytes: Box + Send + Sync>, default_header: IndexHeader, ) -> Result { let header = diff --git a/rust/hg-cpython/src/revlog.rs b/rust/hg-cpython/src/revlog.rs --- a/rust/hg-cpython/src/revlog.rs +++ b/rust/hg-cpython/src/revlog.rs @@ -520,7 +520,7 @@ unsafe fn mmap_keeparound( data: PyObject, ) -> PyResult<( PyBuffer, - Box + Send + 'static>, + Box + Send + Sync + 'static>, )> { let buf = PyBuffer::get(py, &data)?; let len = buf.item_count();