XRootD
Loading...
Searching...
No Matches
XrdCl::XCpSrc Class Reference

#include <XrdClXCpSrc.hh>

+ Collaboration diagram for XrdCl::XCpSrc:

Public Member Functions

 XCpSrc (uint32_t chunkSize, uint8_t parallel, int64_t fileSize, XCpCtx *ctx)
 
void Delete ()
 
bool HasData ()
 
bool IsRunning ()
 
XCpSrcSelf ()
 
void Start ()
 
void Stop ()
 
uint64_t TransferRate ()
 

Static Public Member Functions

static void DeleteChunk (PageInfo *&chunk)
 

Friends

class ChunkHandler
 

Detailed Description

Definition at line 37 of file XrdClXCpSrc.hh.

Constructor & Destructor Documentation

◆ XCpSrc()

XrdCl::XCpSrc::XCpSrc ( uint32_t  chunkSize,
uint8_t  parallel,
int64_t  fileSize,
XCpCtx ctx 
)

Constructor.

Parameters
chunkSize: default chunk size
parallel: number of parallel chunks
fileSize: file size if available (e.g. in metalink file), should be set to -1 if not available, in this case a stat will be performed during initialization
ctx: Extreme Copy context

Definition at line 110 of file XrdClXCpSrc.cc.

110 :
111 pChunkSize( chunkSize ), pParallel( parallel ), pFileSize( fileSize ), pThread(),
112 pCtx( ctx->Self() ), pFile( 0 ), pCurrentOffset( 0 ), pBlkEnd( 0 ), pDataTransfered( 0 ), pRefCount( 1 ),
113 pRunning( false ), pStartTime( 0 ), pTransferTime( 0 ), pUsePgRead( false )
114{
115}

Member Function Documentation

◆ Delete()

void XrdCl::XCpSrc::Delete ( )
inline

Deletes the instance if the reference counter reached 0.

Definition at line 71 of file XrdClXCpSrc.hh.

72 {
73 XrdSysMutexHelper lck( pMtx );
74 --pRefCount;
75 if( !pRefCount )
76 {
77 lck.UnLock();
78 delete this;
79 }
80 }

References XrdSysMutexHelper::UnLock().

Referenced by XrdCl::ChunkHandler::~ChunkHandler().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DeleteChunk()

static void XrdCl::XCpSrc::DeleteChunk ( PageInfo *&  chunk)
inlinestatic

Delete ChunkInfo object, and set the pointer to null.

Parameters
chunk: the chunk to be deleted

Definition at line 126 of file XrdClXCpSrc.hh.

127 {
128 if( chunk )
129 {
130 delete[] static_cast<char*>( chunk->GetBuffer() );
131 delete chunk;
132 chunk = 0;
133 }
134 }

References XrdCl::PageInfo::GetBuffer().

+ Here is the call graph for this function:

◆ HasData()

bool XrdCl::XCpSrc::HasData ( )
inline
Returns
true if the source has a block of non zero size / some chunks allocated, false otherwise

Definition at line 106 of file XrdClXCpSrc.hh.

107 {
108 XrdSysMutexHelper lck( pMtx );
109 return pCurrentOffset < pBlkEnd || !pRecovered.empty() || !pOngoing.empty();
110 }

Referenced by XrdCl::XCpCtx::WeakestLink().

+ Here is the caller graph for this function:

◆ IsRunning()

bool XrdCl::XCpSrc::IsRunning ( )
inline
Returns
: true if the thread is running, false otherwise

Definition at line 97 of file XrdClXCpSrc.hh.

98 {
99 return pRunning;
100 }

◆ Self()

XCpSrc * XrdCl::XCpSrc::Self ( )
inline

Increments the reference counter.

Returns
: myself.

Definition at line 87 of file XrdClXCpSrc.hh.

88 {
89 XrdSysMutexHelper lck( pMtx );
90 ++pRefCount;
91 return this;
92 }

◆ Start()

void XrdCl::XCpSrc::Start ( )

Creates new thread with XCpSrc::Run as the start routine.

Definition at line 123 of file XrdClXCpSrc.cc.

124{
125 pRunning = true;
126 int rc = pthread_create( &pThread, 0, Run, this );
127 if( rc )
128 {
129 pRunning = false;
130 pCtx->RemoveSrc( this );
131 pCtx->Delete();
132 }
133}
void RemoveSrc(XCpSrc *src)

References XrdCl::XCpCtx::Delete(), and XrdCl::XCpCtx::RemoveSrc().

Referenced by XrdCl::XCpCtx::Initialize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Stop()

void XrdCl::XCpSrc::Stop ( )
inline

Stops the thread.

Definition at line 63 of file XrdClXCpSrc.hh.

64 {
65 pRunning = false;
66 }

◆ TransferRate()

uint64_t XrdCl::XCpSrc::TransferRate ( )

Get the transfer rate for current source

Returns
: transfer rate for current source [B/s]

Definition at line 584 of file XrdClXCpSrc.cc.

585{
586 time_t duration = pTransferTime + time( 0 ) - pStartTime;
587 return pDataTransfered / ( duration + 1 ); // add one to avoid floating point exception
588}

Referenced by XrdCl::XCpCtx::WeakestLink().

+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ ChunkHandler

friend class ChunkHandler
friend

Definition at line 39 of file XrdClXCpSrc.hh.


The documentation for this class was generated from the following files: