Logo Search packages:      
Sourcecode: dar version File versions

libdar::cache Class Reference

#include <cache.hpp>

Inheritance diagram for libdar::cache:


List of all members.

Detailed Description

the cache class implements a very basic read/write caching mechanisme

it is intended to reduce context switches when no compression is used and when reading or writing catalogue through a pipe. The catalogue read and write is done by calling dump/constructor methods of the many objects that a catalogue can contain. This makes a lot of small read or write, which make very poor performances when used over the network through a pipe to ssh. When compression is used, the problem disapears as the compression engine gather theses many small read or write into much bigger ones. This in only when there is no compression that that this class is useful (and used).

Definition at line 50 of file cache.hpp.

Public Member Functions

 cache (user_interaction &dialog, generic_file &hidden, U_I initial_size=10240, U_I unused_read_ratio=10, U_I observation_read_number=100, U_I max_size_hit_read_ratio=50, U_I unused_write_ratio=10, U_I observation_write_number=100, U_I max_size_hit_write_ratio=50)
infinint copy_to (generic_file &ref, infinint size)
 copy the given amount to the object in argument
U_32 copy_to (generic_file &ref, U_32 size)
 small copy (up to 4GB) with CRC calculation
void copy_to (generic_file &ref, crc &value)
 copy all data from the current position to the object in argument and computes a CRC value of the transmitted data
void copy_to (generic_file &ref)
 copy all data from current position to the object in argument
bool diff (generic_file &f)
 compares the contents with the object in argument
void get_crc (crc &val)
 get CRC of the transfered date since last reset
user_interactionget_gf_ui () const
 get the cached user_interaction for inherited classes in particular (this stay a public method, not a protected one)
gf_mode get_mode () const
 retreive the openning mode for this object
infinint get_position ()
 get the current read/write position
S_I read (char *a, size_t size)
 read data from the generic_file
S_I read_back (char &a)
 skip back one char, read on char and skip back one char
S_I read_forward (char &a)
 read one char
void reset_crc ()
 reset CRC on read or writen data
bool skip (const infinint &pos)
 skip at the absolute position
bool skip_relative (S_I x)
 skip relatively to the current position
bool skip_to_eof ()
 skip to the end of file
S_I write (const std::string &arg)
 write a string to the generic_file
S_I write (char *a, size_t size)
 write data to the generic_file

Protected Member Functions

S_I inherited_read (char *a, size_t size)
S_I inherited_write (char *a, size_t size)
void set_mode (gf_mode x)

Private Member Functions

void clear_read ()
void flush_write ()
void fulfill_read ()

Private Attributes

struct buf buffer_cache
bool read_mode
U_I read_obs
U_I read_overused_rate
U_I read_unused_rate
U_I stat_read_counter
U_I stat_read_overused
U_I stat_read_unused
U_I stat_write_counter
U_I stat_write_overused
U_I write_obs
U_I write_overused_rate
U_I write_unused_rate


struct  buf

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index