| Disk ARchive 2.5.10 Full featured and portable backup and archiving tool

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

slave_thread.hpp
Go to the documentation of this file.
1 /*********************************************************************/
2 // dar - disk archive - a backup/restoration program
3 // Copyright (C) 2002-2052 Denis Corbin
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 //
19 // to contact the author : http://dar.linux.free.fr/email.html
20 /*********************************************************************/
21
26
27
28 #ifndef SLAVE_THREAD_HPP
29 #define SLAVE_THREAD_HPP
30
31 #include "../my_config.h"
32
33 #if HAVE_LIBTHREADAR_LIBTHREADAR_HPP
34 #include <libthreadar/libthreadar.hpp>
35 #endif
36
37 #include "generic_file.hpp"
38 #include "messaging.hpp"
39 #include "erreurs.hpp"
40
41 namespace libdar
42 {
43
44
45 class slave_thread : public libthreadar::thread, public on_pool
46 {
47 public:
53 slave_thread(generic_file *x_data,
54 libthreadar::fast_tampon<char> *x_input_data,
55 libthreadar::fast_tampon<char> *x_output_data,
56 libthreadar::fast_tampon<char> *x_input_ctrl,
57 libthreadar::fast_tampon<char> *x_output_ctrl);
58 slave_thread(const slave_thread & ref) { throw SRC_BUG; };
59 const slave_thread & operator = (const slave_thread & ref) { throw SRC_BUG; };
60
62 bool wake_me_up() const { if(wake_me) { const_cast<slave_thread *>(this)->wake_me = false; return true; } else return false; };
63
64 protected:
65 virtual void inherited_run();
66
67 private:
68 generic_file *data;
69 libthreadar::fast_tampon<char> *input_data;
70 libthreadar::fast_tampon<char> *output_data;
71 libthreadar::fast_tampon<char> *input_ctrl;
72 libthreadar::fast_tampon<char> *output_ctrl;
73
74 messaging_encode answer; //< used to communicate with master thread
75 messaging_decode order; //< used to communicate with master thread
76 unsigned int num; //< size of the read block or to be written block
77 char *ptr; //< address of the block to be written or to be read
78 char data_header; //< the one byte message to prepend data with, when more data block follow to answer a given order
79 char data_header_completed; //< the one byte message to prepend data with, when end of order is reached
80 infinint read_ahead; //< amount of data sent for reading and not yet asked for reading
81 bool endless_read_ahead; //< whether an endeless read ahead request has been asked
82 infinint to_send_ahead; //< remaining amount of data to send for the requested read_ahead
83 U_I immediate_read; //< next action is to read this amount of data
84 bool stop; //< whether thread end has been asked
85 bool wake_me; //< whether we ask the master awake us
86
87 void init();
88 void set_header_vars(); //< set the value of data_header and data_header_completed fields
89 void read_order(); //< \note ptr must be released/recycled after this call
90 void send_answer(); //< send the answer to the last order received
91 bool pending_order() { return input_ctrl->is_not_empty(); };
92 bool pending_input_data() { return input_data->is_not_empty(); };
93 void treat_input_data(); //< empty input_data and write down the data
94 void ask_to_wake_me_up(); //< ask the master to wake the slave upon possible action
95
103 U_I send_data_block(U_I size, bool & eof);
104
105 bool treat_order(); //< \return true if answer is prepared and must be sent back to the master thread
106
108 void go_read();
109 };
110
111 } // end of namespace
112
113 #endif
generic_file.hpp
class generic_file is defined here as well as class fichierthe generic_file interface is widely used ...
messaging.hpp
messaging_decode and messaging_encode are used to insert messages in a flow if data blocks ...
erreurs.hpp
contains all the excetion class thrown by libdar
libdar
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47