@@ -69,6 +69,8 @@ struct PageEntry
6969
7070class PageLock : public SRWLockBase <PageLock>
7171{
72+ PageEntry* entry_;
73+
7274public:
7375 PageLock () : SRWLockBase(), entry_(nullptr ) {}
7476
@@ -90,9 +92,6 @@ class PageLock : public SRWLockBase<PageLock>
9092 {
9193 if (is_exclusive) entry_->clear_owner ();
9294 }
93-
94- private:
95- PageEntry* entry_;
9695};
9796
9897// operation result, only for current thread
@@ -108,6 +107,26 @@ struct PageResult
108107
109108class ChunkDiskService
110109{
110+ std::vector<FileHandle> part_lock_; // part index -> .lock
111+
112+ std::unique_ptr<std::shared_mutex> mutex_parts_;
113+ std::vector<u64 > part_current_; // part index -> # of chunks
114+ size_t part_current_new_ = 0 ; // part index for new chunks
115+ std::unordered_map<u64 , size_t > chunk_parts_; // chunk index -> part index
116+
117+ std::unique_ptr<std::shared_mutex> mutex_pages_;
118+ // BLOCK_SIZE -> PAGE_SIZE access
119+ // read cache, write through
120+ // add to back, evict from front
121+ Map<u64 , PageEntry> cached_pages_;
122+
123+ std::unique_ptr<std::shared_mutex> mutex_unmapped_;
124+ // chunk index -> [start_off, end_off)
125+ std::unordered_map<u64 , std::map<u64 , u64 >> chunk_unmapped_;
126+
127+ // not movable
128+ std::atomic<u64 > post_ft_ = 0 ;
129+
111130public:
112131 const ChunkDiskParams params;
113132
@@ -184,26 +203,6 @@ class ChunkDiskService
184203 void SetPostFileTime (u64 ft) { post_ft_.store (ft, std::memory_order_release); }
185204
186205private:
187- std::vector<FileHandle> part_lock_; // part index -> .lock
188-
189- std::unique_ptr<std::shared_mutex> mutex_parts_;
190- std::vector<u64 > part_current_; // part index -> # of chunks
191- size_t part_current_new_ = 0 ; // part index for new chunks
192- std::unordered_map<u64 , size_t > chunk_parts_; // chunk index -> part index
193-
194- std::unique_ptr<std::shared_mutex> mutex_pages_;
195- // BLOCK_SIZE -> PAGE_SIZE access
196- // read cache, write through
197- // add to back, evict from front
198- Map<u64 , PageEntry> cached_pages_;
199-
200- std::unique_ptr<std::shared_mutex> mutex_unmapped_;
201- // chunk index -> [start_off, end_off)
202- std::unordered_map<u64 , std::map<u64 , u64 >> chunk_unmapped_;
203-
204- // not movable
205- std::atomic<u64 > post_ft_ = 0 ;
206-
207206 // lk: mutex_pages_, shared
208207 // it: from cached_pages_ while holding lk
209208 // return ERROR_LOCK_FAILED if it is locked by the current thread
0 commit comments