tantivy icon indicating copy to clipboard operation
tantivy copied to clipboard

Change wait_merging_threads to take &mut self instead of consuming self

Open rustmailer opened this issue 11 months ago • 0 comments

Issue: wait_merging_threads Consumes self, Making It Difficult to Use in Multi-threaded Environments

The current implementation of wait_merging_threads consumes self, which makes it difficult to use in a multi-threaded environment where IndexWriter is typically wrapped in an Arc<RwLock>. When the program exits, we often need to check if there are any merging threads still running. If the method consumes self, it complicates the code because we would need to take ownership of the IndexWriter from the Arc<RwLock>, which is not straightforward.

Proposed Solution

Change the method signature of wait_merging_threads to take &mut self instead of consuming self. This will allow the method to be called without transferring ownership, making it easier to use in a multi-threaded context.

Related PR

A pull request addressing this issue has already been submitted:
PR #2543: Change wait_merging_threads to take &mut self

rustmailer avatar Mar 19 '25 20:03 rustmailer