thin-provisioning-tools/thin-provisioning/cache_stream.h

52 lines
1.0 KiB
C
Raw Normal View History

#ifndef THIN_PROVISIONING_CACHE_STREAM_H
#define THIN_PROVISIONING_CACHE_STREAM_H
#include "thin-provisioning/chunk_stream.h"
//----------------------------------------------------------------
namespace thin_provisioning {
using namespace bcache;
class cache_stream : public chunk_stream {
public:
cache_stream(std::string const &path,
block_address block_size,
size_t cache_mem);
2015-09-04 19:46:49 +05:30
block_address size() const;
2015-09-03 17:32:29 +05:30
virtual void rewind();
2015-09-03 17:32:29 +05:30
virtual bool next(block_address count = 1ull);
virtual bool eof() const;
virtual chunk const &get();
virtual void put(chunk const &c);
private:
2015-09-03 17:32:29 +05:30
struct chunk_wrapper {
chunk_wrapper(cache_stream &parent);
block_cache::auto_block block_;
chunk c_;
};
friend struct chunk_wrapper;
block_address block_size_;
block_address nr_blocks_;
block_address cache_blocks_;
2015-09-03 17:32:29 +05:30
file_utils::file_descriptor fd_;
validator::ptr v_;
2017-03-13 18:50:52 +05:30
std::unique_ptr<block_cache> cache_;
block_address current_index_;
};
}
//----------------------------------------------------------------
#endif