xrootd
XrdClientThread.hh
Go to the documentation of this file.
1 
2 // //
3 // XrdClientThread //
4 // //
5 // An user friendly thread wrapper //
6 // Author: F.Furano (INFN, 2005) //
7 // //
9 
10 // $Id$
11 
12 #ifndef XRC_THREAD_H
13 #define XRC_THREAD_H
14 
15 #include "XrdSys/XrdSysPthread.hh"
16 
17 void * XrdClientThreadDispatcher(void * arg);
18 
20 private:
21  pthread_t fThr;
22 
23  typedef void *(*VoidRtnFunc_t)(void *, XrdClientThread *);
25  friend void *XrdClientThreadDispatcher(void *);
26 
27  public:
29  void *arg;
31  } fArg;
32 
33 
35 #ifndef WIN32
36  fThr = 0;
37 #endif
38  ThreadFunc = fn;
39  };
40 
41  virtual ~XrdClientThread() {
42 
43 // Cancel();
44  };
45 
46  int Cancel() {
47  return XrdSysThread::Cancel(fThr);
48  };
49 
50  int Run(void *arg = 0) {
51  fArg.arg = arg;
52  fArg.threadobj = this;
54  XRDSYSTHREAD_HOLD, "");
55  };
56 
57  int Detach() {
58  return XrdSysThread::Detach(fThr);
59  };
60 
61  int Join(void **ret = 0) {
62  return XrdSysThread::Join(fThr, ret);
63  };
64 
65  // these funcs are to be called only from INSIDE the thread loop
66  int SetCancelOn() {
68  };
69  int SetCancelOff() {
71  };
74  };
77  };
78  void CancelPoint() {
80  };
81 
82  int MaskSignal(int snum = 0, bool block = 1);
83 };
84 
85 
86 
87 #endif