From 99da69c85fdc1cd253b1cd65f6275927e4c6d33b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Fri, 30 Oct 2020 11:46:14 +0100 Subject: [PATCH] Introduce the prepare_for_closing Index method --- src/index.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/index.rs b/src/index.rs index 0520ae041..3de742d22 100644 --- a/src/index.rs +++ b/src/index.rs @@ -64,6 +64,15 @@ impl Index { self.env.path() } + /// Returns an `EnvClosingEvent` that can be used to wait for the closing event, + /// multiple threads can wait on this event. + /// + /// Make sure that you drop all the copies of `Index`es you have, env closing are triggered + /// when all references are dropped, the last one will eventually close the environment. + pub fn prepare_for_closing(self) -> heed::EnvClosingEvent { + self.env.prepare_for_closing() + } + /// Writes the documents ids that corresponds to the user-ids-documents-ids FST. pub fn put_documents_ids(&self, wtxn: &mut heed::RwTxn, docids: &RoaringBitmap) -> heed::Result<()> { self.main.put::<_, Str, RoaringBitmapCodec>(wtxn, DOCUMENTS_IDS_KEY, docids)