XRootD
XrdEcUtilities.cc
Go to the documentation of this file.
1
//------------------------------------------------------------------------------
2
// Copyright (c) 2011-2014 by European Organization for Nuclear Research (CERN)
3
// Author: Michal Simon <michal.simon@cern.ch>
4
//------------------------------------------------------------------------------
5
// This file is part of the XRootD software suite.
6
//
7
// XRootD is free software: you can redistribute it and/or modify
8
// it under the terms of the GNU Lesser General Public License as published by
9
// the Free Software Foundation, either version 3 of the License, or
10
// (at your option) any later version.
11
//
12
// XRootD is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
// GNU General Public License for more details.
16
//
17
// You should have received a copy of the GNU Lesser General Public License
18
// along with XRootD. If not, see <http://www.gnu.org/licenses/>.
19
//
20
// In applying this licence, CERN does not waive the privileges and immunities
21
// granted to it by virtue of its status as an Intergovernmental Organization
22
// or submit itself to any jurisdiction.
23
//------------------------------------------------------------------------------
24
25
#include "
XrdEc/XrdEcUtilities.hh
"
26
#include "
XrdCl/XrdClJobManager.hh
"
27
#include "
XrdCl/XrdClPostMaster.hh
"
28
#include "
XrdCl/XrdClDefaultEnv.hh
"
29
30
namespace
XrdEc
31
{
32
//---------------------------------------------------------------------------
33
// A job for scheduling the user callback
34
//---------------------------------------------------------------------------
35
class
ResponseJob
:
public
XrdCl::Job
36
{
37
public
:
38
//-----------------------------------------------------------------------
39
// Constructor
40
//-----------------------------------------------------------------------
41
ResponseJob
(
XrdCl::ResponseHandler
*handler,
42
XrdCl::XRootDStatus
*status,
43
XrdCl::AnyObject
*response ):
44
pHandler( handler ), pStatus( status ), pResponse( response )
45
{
46
}
47
48
virtual
void
Run
(
void
*arg )
49
{
50
pHandler->
HandleResponse
( pStatus, pResponse );
51
delete
this
;
52
}
53
54
private
:
55
56
XrdCl::ResponseHandler
*pHandler;
//< user callback
57
XrdCl::XRootDStatus
*pStatus;
//< operation status
58
XrdCl::AnyObject
*pResponse;
//< user response
59
};
60
61
//---------------------------------------------------------------------------
62
// A utility function for scheduling read operation handler
63
//---------------------------------------------------------------------------
64
void
ScheduleHandler
( uint64_t offset, uint32_t size,
void
*buffer,
XrdCl::ResponseHandler
*handler )
65
{
66
if
( !handler )
return
;
67
68
XrdCl::ChunkInfo
*chunk =
new
XrdCl::ChunkInfo
();
69
chunk->
offset
= offset;
70
chunk->
length
= size;
71
chunk->
buffer
= buffer;
72
73
XrdCl::AnyObject
*resp =
new
XrdCl::AnyObject
();
74
resp->
Set
( chunk );
75
76
ResponseJob
*job =
new
ResponseJob
( handler,
new
XrdCl::XRootDStatus
(), resp );
77
XrdCl::DefaultEnv::GetPostMaster
()->
GetJobManager
()->
QueueJob
( job );
78
}
79
80
//---------------------------------------------------------------------------
81
// A utility function for scheduling an operation handler
82
//---------------------------------------------------------------------------
83
void
ScheduleHandler
(
XrdCl::ResponseHandler
*handler,
const
XrdCl::XRootDStatus
&st )
84
{
85
if
( !handler )
return
;
86
87
ResponseJob
*job =
new
ResponseJob
( handler,
new
XrdCl::XRootDStatus
( st ), 0 );
88
XrdCl::DefaultEnv::GetPostMaster
()->
GetJobManager
()->
QueueJob
( job );
89
}
90
91
}
XrdClDefaultEnv.hh
XrdClJobManager.hh
XrdClPostMaster.hh
XrdEcUtilities.hh
XrdCl::AnyObject
Definition:
XrdClAnyObject.hh:33
XrdCl::AnyObject::Set
void Set(Type object, bool own=true)
Definition:
XrdClAnyObject.hh:59
XrdCl::DefaultEnv::GetPostMaster
static PostMaster * GetPostMaster()
Get default post master.
Definition:
XrdClDefaultEnv.cc:453
XrdCl::JobManager::QueueJob
void QueueJob(Job *job, void *arg=0)
Add a job to be run.
Definition:
XrdClJobManager.hh:92
XrdCl::Job
Interface for a job to be run by the job manager.
Definition:
XrdClJobManager.hh:34
XrdCl::PostMaster::GetJobManager
JobManager * GetJobManager()
Get the job manager object user by the post master.
Definition:
XrdClPostMaster.cc:307
XrdCl::ResponseHandler
Handle an async response.
Definition:
XrdClXRootDResponses.hh:1127
XrdCl::ResponseHandler::HandleResponse
virtual void HandleResponse(XRootDStatus *status, AnyObject *response)
Definition:
XrdClXRootDResponses.hh:1156
XrdCl::XRootDStatus
Request status.
Definition:
XrdClXRootDResponses.hh:219
XrdEc::ResponseJob
Definition:
XrdEcUtilities.cc:36
XrdEc::ResponseJob::ResponseJob
ResponseJob(XrdCl::ResponseHandler *handler, XrdCl::XRootDStatus *status, XrdCl::AnyObject *response)
Definition:
XrdEcUtilities.cc:41
XrdEc::ResponseJob::Run
virtual void Run(void *arg)
The job logic.
Definition:
XrdEcUtilities.cc:48
XrdEc
Definition:
XrdClZipArchive.hh:45
XrdEc::ScheduleHandler
void ScheduleHandler(uint64_t offset, uint32_t size, void *buffer, XrdCl::ResponseHandler *handler)
Definition:
XrdEcUtilities.cc:64
XrdCl::ChunkInfo
Describe a data chunk for vector read.
Definition:
XrdClXRootDResponses.hh:918
XrdCl::ChunkInfo::buffer
void * buffer
length of the chunk
Definition:
XrdClXRootDResponses.hh:951
XrdCl::ChunkInfo::length
uint32_t length
offset in the file
Definition:
XrdClXRootDResponses.hh:950
XrdCl::ChunkInfo::offset
uint64_t offset
Definition:
XrdClXRootDResponses.hh:949
XrdEc
XrdEcUtilities.cc
Generated by
1.9.1