MCPcopy Create free account
hub / github.com/cosdata/cosdata / close_cursor

Method close_cursor

src/models/buffered_io.rs:183–187  ·  view source on GitHub ↗

@DOUBT: The caller will need to remember to call close_cursor, other wise the cursors will keep accumulating. One way to prevent that can be to implement Drop trait for the Cursor struct. But for that, we'd need to have the cursors hashmap inside an Arc so that a reference to it can be shared with the Cursor struct. Then in the Cursor::drop method, the cursor can be removed from the hashmap.

(&self, cursor_id: u64)

Source from the content-addressed store, hash-verified

181 // Cursor struct. Then in the Cursor::drop method, the cursor can
182 // be removed from the hashmap.
183 pub fn close_cursor(&self, cursor_id: u64) -> Result<(), BufIoError> {
184 let mut cursors = self.cursors.write().map_err(|_| BufIoError::Locking)?;
185 cursors.remove(&cursor_id);
186 Ok(())
187 }
188
189 fn get_or_create_region(&self, position: u64) -> Result<Arc<BufferRegion>, BufIoError> {
190 let start = position - (position % self.buffer_size as u64);

Calls 1

removeMethod · 0.80