xrootd
Main Page
Namespaces
Classes
Files
File List
File Members
src
XrdClient
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
36
#include "
XrdSys/XrdSysPthread.hh
"
37
38
void
*
XrdClientThreadDispatcher
(
void
* arg);
39
40
class
XrdClientThread
{
41
private
:
42
pthread_t
fThr
;
43
44
typedef
void
*(*VoidRtnFunc_t)(
void
*,
XrdClientThread
*);
45
VoidRtnFunc_t
ThreadFunc
;
46
friend
void
*
XrdClientThreadDispatcher
(
void
*);
47
48
public
:
49
struct
XrdClientThreadArgs
{
50
void
*
arg
;
51
XrdClientThread
*
threadobj
;
52
}
fArg
;
53
54
55
XrdClientThread
(
VoidRtnFunc_t
fn) {
56
#ifndef WIN32
57
fThr
= 0;
58
#endif
59
ThreadFunc
= fn;
60
};
61
62
virtual
~XrdClientThread
() {
63
64
// Cancel();
65
};
66
67
int
Cancel
() {
68
return
XrdSysThread::Cancel
(
fThr
);
69
};
70
71
int
Run
(
void
*arg = 0) {
72
fArg
.
arg
= arg;
73
fArg
.
threadobj
=
this
;
74
return
XrdSysThread::Run
(&
fThr
,
XrdClientThreadDispatcher
, (
void
*)&
fArg
,
75
XRDSYSTHREAD_HOLD
,
""
);
76
};
77
78
int
Detach
() {
79
return
XrdSysThread::Detach
(
fThr
);
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
87
int
SetCancelOn
() {
88
return
XrdSysThread::SetCancelOn
();
89
};
90
int
SetCancelOff
() {
91
return
XrdSysThread::SetCancelOff
();
92
};
93
int
SetCancelAsynchronous
() {
94
return
XrdSysThread::SetCancelAsynchronous
();
95
};
96
int
SetCancelDeferred
() {
97
return
XrdSysThread::SetCancelDeferred
();
98
};
99
void
CancelPoint
() {
100
XrdSysThread::CancelPoint
();
101
};
102
103
int
MaskSignal
(
int
snum = 0,
bool
block = 1);
104
};
105
#endif
Generated by
1.8.3.1