XRootD
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 ()
 
int Start ()
 
void Stop ()
 
uint64_t TransferRate ()
 

Static Public Member Functions

static void DeleteChunk (PageInfo *&chunk)
 

Friends

class ChunkHandler
 

Detailed Description

Definition at line 39 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 73 of file XrdClXCpSrc.hh.

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

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 131 of file XrdClXCpSrc.hh.

132  {
133  if( chunk )
134  {
135  delete[] static_cast<char*>( chunk->GetBuffer() );
136  delete chunk;
137  chunk = 0;
138  }
139  }

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 111 of file XrdClXCpSrc.hh.

112  {
113  XrdSysMutexHelper lck( pMtx );
114  return pCurrentOffset < pBlkEnd || !pRecovered.empty() || !pOngoing.empty();
115  }

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 102 of file XrdClXCpSrc.hh.

103  {
104  return pRunning;
105  }

◆ Self()

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

Increments the reference counter.

Returns
: myself.

Definition at line 89 of file XrdClXCpSrc.hh.

90  {
91  XrdSysMutexHelper lck( pMtx );
92  // if Ctx is trying to increase our ref count it is possible
93  // we are already in our destrutor, waiting for RemoveSrc().
94  if( !pRefCount ) return nullptr;
95  ++pRefCount;
96  return this;
97  }

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

+ Here is the caller graph for this function:

◆ Start()

int XrdCl::XCpSrc::Start ( )

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

Definition at line 125 of file XrdClXCpSrc.cc.

126 {
127  pRunning = true;
128  int rc = pthread_create( &pThread, 0, Run, this );
129  if( rc ) pRunning = false;
130  return rc;
131 }

◆ Stop()

void XrdCl::XCpSrc::Stop ( )
inline

Stops the thread.

Definition at line 65 of file XrdClXCpSrc.hh.

66  {
67  pRunning = false;
68  }

◆ TransferRate()

uint64_t XrdCl::XCpSrc::TransferRate ( )

Get the transfer rate for current source

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

Definition at line 596 of file XrdClXCpSrc.cc.

597 {
598  time_t duration = pTransferTime + time( 0 ) - pStartTime;
599  return pDataTransfered / ( duration + 1 ); // add one to avoid floating point exception
600 }

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

+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ ChunkHandler

friend class ChunkHandler
friend

Definition at line 41 of file XrdClXCpSrc.hh.


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