xrootd
XrdClientThread.hh
Go to the documentation of this file.
1#ifndef XRC_THREAD_H
2#define XRC_THREAD_H
3/******************************************************************************/
4/* */
5/* X r d C l i e n t T h r e a d . h h */
6/* */
7/* Author: F.Furano (INFN, 2005) */
8/* */
9/* This file is part of the XRootD software suite. */
10/* */
11/* XRootD is free software: you can redistribute it and/or modify it under */
12/* the terms of the GNU Lesser General Public License as published by the */
13/* Free Software Foundation, either version 3 of the License, or (at your */
14/* option) any later version. */
15/* */
16/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
17/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
18/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
19/* License for more details. */
20/* */
21/* You should have received a copy of the GNU Lesser General Public License */
22/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
23/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
24/* */
25/* The copyright holder's institutional names and contributor's names may not */
26/* be used to endorse or promote products derived from this software without */
27/* specific prior written permission of the institution or contributor. */
28/******************************************************************************/
29
31// //
32// An user friendly thread wrapper //
33// //
35
37
38void * XrdClientThreadDispatcher(void * arg);
39
41private:
42 pthread_t fThr;
43
44 typedef void *(*VoidRtnFunc_t)(void *, XrdClientThread *);
46 friend void *XrdClientThreadDispatcher(void *);
47
48 public:
50 void *arg;
53
54
56#ifndef WIN32
57 fThr = 0;
58#endif
59 ThreadFunc = fn;
60 };
61
62 virtual ~XrdClientThread() {
63
64// Cancel();
65 };
66
67 int Cancel() {
69 };
70
71 int Run(void *arg = 0) {
72 fArg.arg = arg;
73 fArg.threadobj = this;
76 };
77
78 int Detach() {
80 };
81
82 int Join(void **ret = 0) {
83 return XrdSysThread::Join(fThr, ret);
84 };
85
86 // these funcs are to be called only from INSIDE the thread loop
89 };
92 };
95 };
98 };
99 void CancelPoint() {
101 };
102
103 int MaskSignal(int snum = 0, bool block = 1);
104};
105#endif
void * XrdClientThreadDispatcher(void *arg)
#define XRDSYSTHREAD_HOLD
Definition: XrdSysPthread.hh:458
Definition: XrdClientThread.hh:40
virtual ~XrdClientThread()
Definition: XrdClientThread.hh:62
int SetCancelOn()
Definition: XrdClientThread.hh:87
struct XrdClientThread::XrdClientThreadArgs fArg
pthread_t fThr
Definition: XrdClientThread.hh:42
int SetCancelDeferred()
Definition: XrdClientThread.hh:96
int SetCancelOff()
Definition: XrdClientThread.hh:90
friend void * XrdClientThreadDispatcher(void *)
int Run(void *arg=0)
Definition: XrdClientThread.hh:71
int MaskSignal(int snum=0, bool block=1)
int Cancel()
Definition: XrdClientThread.hh:67
int Join(void **ret=0)
Definition: XrdClientThread.hh:82
VoidRtnFunc_t ThreadFunc
Definition: XrdClientThread.hh:45
void CancelPoint()
Definition: XrdClientThread.hh:99
int Detach()
Definition: XrdClientThread.hh:78
void *(* VoidRtnFunc_t)(void *, XrdClientThread *)
Definition: XrdClientThread.hh:44
XrdClientThread(VoidRtnFunc_t fn)
Definition: XrdClientThread.hh:55
int SetCancelAsynchronous()
Definition: XrdClientThread.hh:93
static void CancelPoint()
Definition: XrdSysPthread.hh:489
static int SetCancelAsynchronous()
Definition: XrdSysPthread.hh:481
static int Join(pthread_t tid, void **ret)
Definition: XrdSysPthread.hh:473
static int Cancel(pthread_t tid)
Definition: XrdSysPthread.hh:464
static int SetCancelOn()
Definition: XrdSysPthread.hh:477
static int Run(pthread_t *, void *(*proc)(void *), void *arg, int opts=0, const char *desc=0)
static int Detach(pthread_t tid)
Definition: XrdSysPthread.hh:466
static int SetCancelOff()
Definition: XrdSysPthread.hh:469
static int SetCancelDeferred()
Definition: XrdSysPthread.hh:485
Definition: XrdClientThread.hh:49
void * arg
Definition: XrdClientThread.hh:50
XrdClientThread * threadobj
Definition: XrdClientThread.hh:51