IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
CliCollPeersCB Class Reference

class CliCollPeersCB More...

Inheritance diagram for CliCollPeersCB:
ipsdk::tcpip::CollPeersCB

Public Member Functions

virtual ~CliCollPeersCB ()
 destructor
 
void join ()
 waits for all the threads of the threads pool to terminate and for the clients to be closed
 
- Public Member Functions inherited from ipsdk::tcpip::CollPeersCB
 CollPeersCB ()
 
virtual ~CollPeersCB ()
 

Static Public Member Functions

static boost::shared_ptr< CliCollPeersCBcreate (const std::string &ipAddr, unsigned short nPortNumber, ipUInt16 nbThreads, ipUInt32 nbBuffers, ipUInt32 nbBytesPerBuffer, eSocketsMode socketsMode)
 creates a new instance of boost::shared_ptr<CliCollPeersCB> More...
 

Protected Member Functions

 CliCollPeersCB (const std::string &ipAddr, unsigned short nPortNumber, ipUInt16 nbThreads, ipUInt32 nbBuffers, ipUInt32 nbBytesPerBuffer, eSocketsMode socketsMode)
 constructor More...
 
void setCollPeers (boost::shared_ptr< CollPeers > pCollPeers)
 attaches a CollPeers object, and creates clients (depending on current sockets mode) that will connect to the server side on ip address listen port passed as argument of the constructor. CB methods of the class will be called when events associated to this CollPeers object will occur
 
ipUInt16 getNbExpectedSockets ()
 
void deliver (const Guid &rcvSocketGuid, const SerializationObjectPtr &pObj, const DlvCbFun &f=0)
 delivers the object 'pObj' to the server, through the writeSocket if current More...
 
void askForBuffers ()
 wakes up all threads, so that they deliver an AskForBuffer object to the server side
 
void addBenchResult ()
 adds a new bench result, with the current test configuration name
 
void threadFun (unsigned int nThreadId, const ipsdk::Guid &socketGuid)
 function run by each working thread More...
 
virtual void onConnected (const tcpip::SocketDesc &socketDesc)
 overload of the callback method onConnected once all expected sockets are connected, delivers the ServerCfg object to the server side
 
virtual void onListenFailed (ipsdk::ipUInt16 acceptorId, const boost::system::error_code &ec)
 overload of the callback method onListenFailed
 
virtual void onConnectionFailed (const Guid &peerId, const EndPoint &remoteEndPoint, const boost::system::error_code &ec)
 overload of the callback method onConnectionFailed
 
virtual void onDeliveryFailed (const Guid &peerId, ipUInt64 nDeliveryId)
 overload of the callback method onDeliveryFailed
 
eSocketUsage getServerSocketUsage (const Guid &socketGuid)
 return the usage mode of the socket, seen from the server side
 
virtual void onRead (const tcpip::SocketDesc &socketDesc, const SerializationObjectPtr pObj)
 overload of the callback method onRead
 
- Protected Member Functions inherited from ipsdk::tcpip::CollPeersCB
virtual void onDelivered (const SocketDesc &socketDesc, ipUInt64 nDeliveryId)
 method called each time a delivery request succeeds More...
 
virtual void onConnectionLost (const SocketDesc &socketDesc, const boost::system::error_code &ec)
 method called each time an active connection is broken More...
 
virtual void onConnectionClosed (const Guid &peerId, bool bOnUserRequest)
 method called when a connection is closed (follows a server connection break, or a user close request) More...
 

Protected Attributes

ipUInt16 _nbThreads
 number of implemented working threads
 
ServerCfg _serverCfg
 current tested configuration
 
std::set< Guid_sockets
 collection of identifiers of implemented sockets
 
std::string _ipAddr
 IP address of the server.
 
unsigned short _nPortNumber
 listening TCP/IP port number
 
CollPeersPtr _pCollPeers
 CollPeers object used to communicate with server side.
 
boost::thread_group _threadsGroup
 working threads pool
 
Guid _readSocketGuid
 
Guid _writeSocketGuid
 
std::vector< int > _askForBuffer
 
std::vector< int > _writeBuffer
 
std::vector< int > _stopThread
 
std::vector< BufferPtr > _buffersToReturn
 collection storing buffers that have to be sent back to server
 
std::vector< MutexPtr > _mutex
 
std::vector< CondPtr > _cond
 
Chrono _chrono
 

Detailed Description

class CliCollPeersCB

Constructor & Destructor Documentation

◆ CliCollPeersCB()

CliCollPeersCB::CliCollPeersCB ( const std::string &  ipAddr,
unsigned short  nPortNumber,
ipUInt16  nbThreads,
ipUInt32  nbBuffers,
ipUInt32  nbBytesPerBuffer,
eSocketsMode  socketsMode 
)
inlineprotected

constructor

Note
the constructor of this class has been made protected, to prevent the user from creating a CliCollPeersCB from the stack, because it inherits from enable_shared_from_this<>. Please use create static method to create a new CliCollPeersCB object
Parameters
ipAddrIP address of the server to which to connect
nPortNumberlistening TCP/IP port
nbThreadsnumber of threads exchanging data with the server
nbBuffersnumber of buffers available from server
nbBytesPerBuffersize (in bytes) of buffers available from server
socketsModemode of sockets (one socket for all threads/one socket per thread/one read socket and one write socket for all threads)

Member Function Documentation

◆ create()

static boost::shared_ptr<CliCollPeersCB> CliCollPeersCB::create ( const std::string &  ipAddr,
unsigned short  nPortNumber,
ipUInt16  nbThreads,
ipUInt32  nbBuffers,
ipUInt32  nbBytesPerBuffer,
eSocketsMode  socketsMode 
)
inlinestatic

creates a new instance of boost::shared_ptr<CliCollPeersCB>

Note
the constructor of this class has been made protected, to prevent the user from creating a CliCollPeersCB from the stack, because it inherits from enable_shared_from_this<>. Please use create static method to create a new CliCollPeersCB object
Parameters
ipAddrIP address of the server to which to connect
nPortNumberlistening TCP/IP port
nbThreadsnumber of threads exchanging data with the server
nbBuffersnumber of buffers available from server
nbBytesPerBuffersize (in bytes) of buffers available from server
socketsModemode of sockets (one socket for all threads/one socket per thread/one read socket and one write socket for all threads)

◆ getNbExpectedSockets()

ipUInt16 CliCollPeersCB::getNbExpectedSockets ( )
inlineprotected

returns the number of expected sockets, depending on current number of threads and current sockets mode

◆ deliver()

void CliCollPeersCB::deliver ( const Guid rcvSocketGuid,
const SerializationObjectPtr pObj,
const DlvCbFun f = 0 
)
inlineprotected

delivers the object 'pObj' to the server, through the writeSocket if current

socketsMode equals "OneSocketForReadOneSocketForWrite", or through the socket passed as argument otherwise

◆ threadFun()

void CliCollPeersCB::threadFun ( unsigned int  nThreadId,
const ipsdk::Guid socketGuid 
)
inlineprotected

function run by each working thread

Parameters
nThreadIdidentifier of the working thread (from 0 to _nbThreads)
socketGuididentifier of the associated socketGuid (not used in "oneSocketForReadOneSocketForWrite" socket mode)

Member Data Documentation

◆ _readSocketGuid

Guid CliCollPeersCB::_readSocketGuid
protected

GUID of read socket (used in "oneSocketForReadOneSocketForWrite" SocketsMode only

◆ _writeSocketGuid

Guid CliCollPeersCB::_writeSocketGuid
protected

GUID of write socket (used in "oneSocketForReadOneSocketForWrite" SocketsMode only

◆ _askForBuffer

std::vector<int> CliCollPeersCB::_askForBuffer
protected

sync variable, used by each working thread to determine if an AskForBuffer object delivery is needed

◆ _writeBuffer

std::vector<int> CliCollPeersCB::_writeBuffer
protected

sync variable, used by each working thread to determine if a Buffer object delivery is needed

◆ _stopThread

std::vector<int> CliCollPeersCB::_stopThread
protected

sync variable, used by each working thread to determine if it has to terminate

◆ _mutex

std::vector<MutexPtr> CliCollPeersCB::_mutex
protected

mutex protecting access to sync variables _askForBuffer, _writeBuffer, _stopThread and _buffersToReturn

◆ _cond

std::vector<CondPtr> CliCollPeersCB::_cond
protected

condition variables used with sync variables _askForBuffer, _writeBuffer, _stopThread and _buffersToReturn

◆ _chrono

Chrono CliCollPeersCB::_chrono
protected

chrono used to estimate time elapsed between first emission of AskForBuffer object and last working thread termination


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