Disk ARchive
2.7.15
Full featured and portable backup and archiving tool
|
this is a partial implementation of the generic_file interface to cypher/decypher data block by block. More...
#include <parallel_tronconneuse.hpp>
Inherits libdar::proto_tronco.
Public Member Functions | |
parallel_tronconneuse (U_I workers, U_32 block_size, generic_file &encrypted_side, const archive_version &reading_ver, std::unique_ptr< crypto_module > &ptr) | |
This is the constructor. More... | |
parallel_tronconneuse (const parallel_tronconneuse &ref)=delete | |
copy constructor | |
parallel_tronconneuse (parallel_tronconneuse &&ref)=default | |
move constructor | |
parallel_tronconneuse & | operator= (const parallel_tronconneuse &ref)=delete |
assignment operator | |
parallel_tronconneuse & | operator= (parallel_tronconneuse &&ref) noexcept=default |
move operator | |
~parallel_tronconneuse () noexcept | |
destructor | |
virtual bool | skippable (skippability direction, const infinint &amount) override |
inherited from generic_file | |
virtual bool | skip (const infinint &pos) override |
inherited from generic_file | |
virtual bool | skip_to_eof () override |
inherited from generic_file | |
virtual bool | skip_relative (S_I x) override |
inherited from generic_file | |
virtual bool | truncatable (const infinint &pos) const override |
inherited from generic_file | |
virtual infinint | get_position () const override |
inherited from generic_file | |
virtual void | write_end_of_file () override |
in write_only mode indicate that end of file is reached More... | |
virtual void | set_initial_shift (const infinint &x) override |
this method to modify the initial shift. This overrides the constructor "no_initial_shift" of the constructor | |
virtual void | set_callback_trailing_clear_data (trailing_clear_data_callback call_back) override |
virtual U_32 | get_clear_block_size () const override |
returns the block size given to constructor | |
Private Types | |
enum class | thread_status { running , suspended , dead } |
Private Member Functions | |
virtual void | inherited_read_ahead (const infinint &amount) override |
this protected inherited method is now private for inherited classes of tronconneuse | |
virtual U_I | inherited_read (char *a, U_I size) override |
this protected inherited method is now private for inherited classes of tronconneuse | |
virtual void | inherited_write (const char *a, U_I size) override |
inherited from generic_file More... | |
virtual void | inherited_truncate (const infinint &pos) override |
this prorected inherited method is now private for inherited classed of tronconneuse More... | |
virtual void | inherited_sync_write () override |
this protected inherited method is now private for inherited classes of tronconneuse | |
virtual void | inherited_flush_read () override |
this protected inherited method is now private for inherited classes of tronconneuse | |
virtual void | inherited_terminate () override |
this protected inherited method is now private for inherited classes of tronconneuse | |
const archive_version & | get_reading_version () const |
bool | send_read_order (tronco_flags order, const infinint &for_offset=0) |
send and order to subthreads and gather acks from them More... | |
void | send_write_order (tronco_flags order) |
send order in write mode | |
void | go_read () |
wake up threads in read mode when necessary | |
void | read_refill () |
fill lus_data/lus_flags from ratelier_gather if these are empty | |
tronco_flags | purge_ratelier_from_next_order (infinint pos=0) |
purge the ratelier from the next order which is provided as returned value More... | |
bool | purge_unack_stop_order (const infinint &pos=0) |
removing the ignore_stop_acks pending on the pipe More... | |
bool | find_offset_in_lus_data (const infinint &pos) |
flush lus_data/lus_flags up to requested pos offset to be found or all data has been removed More... | |
void | run_threads () |
reset the interthread datastructure and launch the threads | |
void | stop_threads () |
end threads taking into account the fact they may be suspended on the barrier | |
void | join_workers_only () |
call by join_threads() below just code simplification around exception handling | |
void | join_threads () |
wait for threads to finish and eventually rethrow their exceptions in current thread | |
Static Private Member Functions | |
static U_I | get_ratelier_size (U_I num_worker) |
static U_I | get_heap_size (U_I num_worker) |
Private Attributes | |
U_I | num_workers |
number of worker threads | |
U_32 | clear_block_size |
size of a clear block | |
infinint | current_position |
current position for the upper layer perspective (modified by skip*, inherited_read/write, find_offset_in_lus_data) | |
infinint | initial_shift |
the offset in the "encrypted" below layer at which starts the encrypted data | |
archive_version | reading_ver |
archive format we follow | |
std::unique_ptr< crypto_module > | crypto |
the crypto module use to cipher / uncipher block of data | |
infinint(* | mycallback )(generic_file &below, const archive_version &reading_ver) |
generic_file * | encrypted |
U_I | ignore_stop_acks |
how much stop ack still to be read (aborted stop order context) | |
thread_status | t_status |
wehther child thread are waiting us on the barrier | |
std::deque< std::unique_ptr< crypto_segment > > | lus_data |
std::deque< signed int > | lus_flags |
bool | lus_eof |
bool | check_bytes_to_skip |
whether to check for bytes to skip | |
std::unique_ptr< crypto_segment > | tempo_write |
infinint | block_num |
std::shared_ptr< libthreadar::ratelier_scatter< crypto_segment > > | scatter |
std::shared_ptr< libthreadar::ratelier_gather< crypto_segment > > | gather |
std::shared_ptr< libthreadar::barrier > | waiter |
std::shared_ptr< heap< crypto_segment > > | tas |
std::deque< std::unique_ptr< crypto_worker > > | travailleur |
std::unique_ptr< read_below > | crypto_reader |
std::unique_ptr< write_below > | crypto_writer |
this is a partial implementation of the generic_file interface to cypher/decypher data block by block.
This class is a pure virtual one, as several calls have to be defined by inherited classes
parallel_tronconneuse is either read_only or write_only, read_write is not allowed. The openning mode is defined by encrypted_side's mode. In write_only no skip() is allowed, writing is sequential from the beginning of the file to the end (like writing to a pipe). In read_only all skip() functions are available.
Definition at line 88 of file parallel_tronconneuse.hpp.
libdar::parallel_tronconneuse::parallel_tronconneuse | ( | U_I | workers, |
U_32 | block_size, | ||
generic_file & | encrypted_side, | ||
const archive_version & | reading_ver, | ||
std::unique_ptr< crypto_module > & | ptr | ||
) |
This is the constructor.
[in] | workers | is the number of worker threads |
[in] | block_size | is the size of block encryption (the size of clear data encrypted toghether). |
[in] | encrypted_side | where encrypted data are read from or written to. |
[in] | reading_ver | version of the archive format |
[in] | ptr | pointer to an crypto_module object that will be passed to the parallel_tronconneuse |
|
private |
flush lus_data/lus_flags up to requested pos offset to be found or all data has been removed
[in] | pos | the data offset we look for |
|
inlineoverrideprivatevirtual |
this prorected inherited method is now private for inherited classed of tronconneuse
Implements libdar::generic_file.
Definition at line 174 of file parallel_tronconneuse.hpp.
|
overrideprivatevirtual |
inherited from generic_file
this protected inherited method is now private for inherited classes of tronconneuse
Implements libdar::generic_file.
|
private |
purge the ratelier from the next order which is provided as returned value
[in] | pos | if pos is not zero, the normal data located at pos offset is also looked for. If it is found before any order the call returns tronco_flags::normal and the order is not purged but the ignore_stop_acks fields is set to true for further reading to skip over this order acknolegments. |
|
private |
removing the ignore_stop_acks pending on the pipe
[in] | pos | if pos is not zero and normal data is found at pos offset before all stop acks could get read, the call stops and return false. Else true is returned meaning all stop acks has been read and removed from the pope |
|
private |
send and order to subthreads and gather acks from them
[in] | order | is the order to send to the subthreads |
[in] | for_offset | is not zero is the offset we want to skip to (it is only taken into account when order is stop) |
|
overridevirtual |
let the caller give a callback function that given a generic_file with cyphered data, is able to return the offset of the first clear byte located after all the cyphered data, this callback function is used (if defined by the following method), when reaching End of File.
|
inlineoverridevirtual |
in write_only mode indicate that end of file is reached
this call must be called in write mode to purge the internal cache before deleting the object (else some data may be lost) no further write call is allowed
Definition at line 140 of file parallel_tronconneuse.hpp.
References libdar::generic_file::is_terminated().