parallel_processor/memory_fs/flushable_buffer.rs
1use crate::memory_fs::allocator::AllocatedChunk;
2use crate::memory_fs::file::internal::FileChunk;
3use parking_lot::lock_api::ArcRwLockWriteGuard;
4use parking_lot::{Mutex, RawRwLock};
5use std::sync::Arc;
6
7use super::file::handle::FileHandle;
8
9pub struct FlushableItem {
10 pub underlying_file: Arc<Mutex<FileHandle>>,
11 pub mode: FileFlushMode,
12}
13pub enum FileFlushMode {
14 Append {
15 chunk: ArcRwLockWriteGuard<RawRwLock, FileChunk>,
16 },
17 WriteAt {
18 buffer: AllocatedChunk,
19 offset: u64,
20 },
21}
22
23// impl Drop for FlushableItem {
24// fn drop(&mut self) {
25// if Arc::strong_count(&self.underlying_file) == 1 {
26// unsafe {
27// FILES_FLUSH_HASH_MAP
28// .as_mut()
29// .unwrap()
30// .lock()
31// .entry(self.underlying_file.0.clone())
32// .or_insert(Vec::new())
33// .push(self.underlying_file.clone())
34// }
35// }
36//
37// BUFFER_MANAGER.notify_drop()
38// }
39// }