Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00034
00035 #ifndef THREAD_CANCELLATION_HPP
00036 #define THREAD_CANCELLATION_HPP
00037
00038 #include "../my_config.h"
00039
00040 extern "C"
00041 {
00042 #if MUTEX_WORKS
00043 #if HAVE_PTHREAD_H
00044 #include <pthread.h>
00045 #endif
00046 #endif
00047 }
00048 #include <list>
00049 #include "integers.hpp"
00050
00051 namespace libdar
00052 {
00053
00055
00062
00063 class thread_cancellation
00064 {
00065 public:
00066
00068 thread_cancellation();
00069
00071 virtual ~thread_cancellation();
00072
00074
00077 void check_self_cancellation() const;
00078
00081
00085 void block_delayed_cancellation(bool mode);
00086
00087
00089
00091 static void init();
00092
00093
00094 #if MUTEX_WORKS
00095
00096
00101 static void cancel(pthread_t tid, bool x_immediate, U_64 x_flag);
00102
00104
00107 static bool cancel_status(pthread_t tid);
00108
00110
00113 static bool clear_pending_request(pthread_t tid);
00114 #endif
00115
00117 static U_I count()
00118 {
00119 #if MUTEX_WORKS
00120 return info.size();
00121 #else
00122 return 0;
00123 #endif
00124 };
00125
00126 #if MUTEX_WORKS
00127 private:
00128
00129
00130
00131 struct fields
00132 {
00133 pthread_t tid;
00134 bool block_delayed;
00135 bool immediate;
00136 bool cancellation;
00137 U_64 flag;
00138 };
00139
00140
00141
00142 fields status;
00143
00144
00145
00146 static pthread_mutex_t access;
00147 static bool initialized;
00148 static std::list<thread_cancellation *> info;
00149 static std::list<fields> preborn;
00150
00151 #endif
00152 };
00153
00154 }
00155
00156 #endif