paul@6 | 1 | #pragma once |
paul@6 | 2 | |
paul@6 | 3 | #include "access_map.h" |
paul@6 | 4 | #include "accessor.h" |
paul@6 | 5 | #include "page_owner.h" |
paul@6 | 6 | |
paul@6 | 7 | #include <mutex> |
paul@6 | 8 | |
paul@6 | 9 | /* A file mapper, associating flexpages with file regions. */ |
paul@6 | 10 | |
paul@6 | 11 | class PageMapper : public PageOwner |
paul@6 | 12 | { |
paul@6 | 13 | protected: |
paul@6 | 14 | AccessMap _map; |
paul@6 | 15 | Accessor *_accessor; |
paul@72 | 16 | Pages *_pages; |
paul@6 | 17 | unsigned int _attached; |
paul@6 | 18 | std::mutex _lock; |
paul@6 | 19 | |
paul@6 | 20 | /* Internal flexpage retrieval methods. */ |
paul@6 | 21 | |
paul@6 | 22 | Flexpage *find(offset_t offset); |
paul@6 | 23 | |
paul@6 | 24 | Flexpage *flexpage(offset_t offset); |
paul@6 | 25 | |
paul@6 | 26 | public: |
paul@72 | 27 | explicit PageMapper(Accessor *accessor, Pages *pages); |
paul@6 | 28 | |
paul@6 | 29 | /* Accounting methods. */ |
paul@6 | 30 | |
paul@6 | 31 | void attach(); |
paul@6 | 32 | |
paul@6 | 33 | unsigned int detach(); |
paul@6 | 34 | |
paul@6 | 35 | /* Interface for the pager. */ |
paul@6 | 36 | |
paul@54 | 37 | Flexpage *get(offset_t offset, flags_t flags); |
paul@6 | 38 | |
paul@6 | 39 | void queue(Flexpage *flexpage); |
paul@6 | 40 | |
paul@6 | 41 | void flush_all(offset_t start, offset_t size); |
paul@6 | 42 | |
paul@6 | 43 | offset_t get_data_size(); |
paul@6 | 44 | |
paul@53 | 45 | void set_data_size(offset_t size); |
paul@53 | 46 | |
paul@6 | 47 | /* Data transfer methods, implementing PageOwner. */ |
paul@6 | 48 | |
paul@6 | 49 | void fill(Flexpage *flexpage); |
paul@6 | 50 | |
paul@6 | 51 | void flush(Flexpage *flexpage, bool purge); |
paul@6 | 52 | |
paul@6 | 53 | /* Interface for the page collection, implementing PageOwner. */ |
paul@6 | 54 | |
paul@6 | 55 | void remove(Flexpage *flexpage); |
paul@6 | 56 | }; |
paul@6 | 57 | |
paul@6 | 58 | // vim: tabstop=4 expandtab shiftwidth=4 |