Disk ARchive  2.4.17
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules
thread_cancellation.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 
34 
35 #ifndef THREAD_CANCELLATION_HPP
36 #define THREAD_CANCELLATION_HPP
37 
38 #include "../my_config.h"
39 
40 extern "C"
41 {
42 #if MUTEX_WORKS
43 #if HAVE_PTHREAD_H
44 #include <pthread.h>
45 #endif
46 #endif
47 }
48 #include <list>
49 #include "integers.hpp"
50 
51 namespace libdar
52 {
53 
55 
62 
64  {
65  public:
66 
69 
71  virtual ~thread_cancellation();
72 
74 
77  void check_self_cancellation() const;
78 
81 
85  void block_delayed_cancellation(bool mode);
86 
87 
89 
91  static void init();
92 
93 
94 #if MUTEX_WORKS
95 
101  static void cancel(pthread_t tid, bool x_immediate, U_64 x_flag);
102 
104 
107  static bool cancel_status(pthread_t tid);
108 
110 
113  static bool clear_pending_request(pthread_t tid);
114 #endif
115 
117  static U_I count()
118  {
119 #if MUTEX_WORKS
120  return info.size();
121 #else
122  return 0;
123 #endif
124  };
125 
126 #if MUTEX_WORKS
127  private:
128 
129  // class types
130 
131  struct fields
132  {
133  pthread_t tid;
134  bool block_delayed;
135  bool immediate;
136  bool cancellation;
137  U_64 flag;
138  };
139 
140  // object information
141 
142  fields status;
143 
144  // class's static variables and types
145 
146  static pthread_mutex_t access;
147  static bool initialized;
148  static std::list<thread_cancellation *> info;
149  static std::list<fields> preborn;
150 
151 #endif
152  };
153 
154 } // end of namespace
155 
156 #endif
are defined here basic integer types that tend to be portable
void block_delayed_cancellation(bool mode)
static U_I count()
method for debugging/control purposes
void check_self_cancellation() const
Checkpoint test : whether the current libdar call must abort or not.
virtual ~thread_cancellation()
the destructor
class to be used as parent to provide checkpoints to inherited classes
thread_cancellation()
the constructor
static void init()
mandatory initialization static method
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:43