Disk ARchive  2.6.8
Full featured and portable backup and archiving tool
slave_thread.hpp
Go to the documentation of this file.
1 /*********************************************************************/
2 // dar - disk archive - a backup/restoration program
3 // Copyright (C) 2002-2020 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 //
19 // to contact the author : http://dar.linux.free.fr/email.html
20 /*********************************************************************/
21 
25 
26 
27 #ifndef SLAVE_THREAD_HPP
28 #define SLAVE_THREAD_HPP
29 
30 #include "../my_config.h"
31 
32 #if HAVE_LIBTHREADAR_LIBTHREADAR_HPP
33 #include <libthreadar/libthreadar.hpp>
34 #endif
35 
36 #include "generic_file.hpp"
37 #include "messaging.hpp"
38 
39 namespace libdar
40 {
41 
44 
45  class slave_thread : public libthreadar::thread
46  {
47  public:
49 
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) = delete;
59  slave_thread(slave_thread && ref) noexcept = delete;
60  slave_thread & operator = (const slave_thread & ref) = delete;
61  slave_thread & operator = (slave_thread && ref) noexcept = delete;
62  ~slave_thread() noexcept {};
63 
65  bool wake_me_up() const { if(wake_me) { const_cast<slave_thread *>(this)->wake_me = false; return true; } else return false; };
66 
67  protected:
68  virtual void inherited_run() override;
69 
70  private:
71  generic_file *data;
72  libthreadar::fast_tampon<char> *input_data;
73  libthreadar::fast_tampon<char> *output_data;
74  libthreadar::fast_tampon<char> *input_ctrl;
75  libthreadar::fast_tampon<char> *output_ctrl;
76 
77  messaging_encode answer;
78  messaging_decode order;
79  unsigned int num;
80  char *ptr;
81  char data_header;
82  char data_header_completed;
83  infinint read_ahead;
84  bool endless_read_ahead;
85  infinint to_send_ahead;
86  U_I immediate_read;
87  bool stop;
88  bool wake_me;
89 
90  void init();
91  void set_header_vars();
92  void read_order();
93  void send_answer();
94  bool pending_order() { return input_ctrl->is_not_empty(); };
95  bool pending_input_data() { return input_data->is_not_empty(); };
96  void treat_input_data();
97  void ask_to_wake_me_up();
98 
100 
106  U_I send_data_block(U_I size, bool & eof);
107 
108  bool treat_order();
109 
111  void go_read();
112  };
113 
115 
116 } // end of namespace
117 
118 #endif
messaging.hpp
messaging_decode and messaging_encode are used to insert messages in a flow of data blocks
generic_file.hpp
class generic_file is defined here as well as class fichier
libdar
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:46