DCMTK  Version 3.6.2
OFFIS DICOM Toolkit
Classes | Public Member Functions | Protected Member Functions | Private Types | Private Attributes | List of all members
DcmBaseSCPPool Class Referenceabstract

Base class for implementing an SCP pool with one thread listening for incoming TCP/IP connections and spawning a number of SCP worker threads that handle the incoming DICOM association on that connection. More...

Classes

class  DcmBaseSCPWorker
 Abstract base class that handles forwarding the configuration and T_ASC_Association to the actual worker class for each worker thread. More...
 

Public Member Functions

virtual ~DcmBaseSCPPool ()
 Virtual destructor, frees internal memory.
 
virtual void setMaxThreads (const Uint16 maxWorkers)
 Set the number of maximum permitted connections, i.e. threads/workers. More...
 
virtual Uint16 getMaxThreads ()
 Get number of maximum permitted connections, i.e. threads/workers. More...
 
virtual size_t numThreads (const OFBool onlyBusy)
 Get number of currently active connections. More...
 
virtual OFCondition listen ()
 Listen for incoming association requests. More...
 
virtual DcmSCPConfiggetConfig ()
 Return handle to the SCP configuration that is used to configure how to handle incoming associations. More...
 
virtual void stopAfterCurrentAssociations ()
 If enabled, the pool will return from listening for incoming requests as soon as the last worker is idle, i.e. no worker is handling a DICOM association any more.
 

Protected Member Functions

 DcmBaseSCPPool ()
 Constructor. More...
 
virtual DcmBaseSCPWorkercreateSCPWorker ()=0
 Create SCP worker. More...
 
OFCondition runAssociation (T_ASC_Association *assoc, const DcmSharedSCPConfig &sharedConfig)
 Try to find worker to run the association. More...
 
virtual void dropAndDestroyAssociation (T_ASC_Association *assoc)
 Drops association and clears internal structures to free memory. More...
 
void rejectAssociation (T_ASC_Association *assoc, const T_ASC_RejectParametersReason &reason)
 Reject association using the given reason, e.g. because maximum number of connections is currently already served. More...
 
void notifyThreadExit (DcmBaseSCPWorker *thread, OFCondition result)
 Used by thread to tell pool it has terminated. More...
 

Private Types

enum  runmode { LISTEN, STOP, SHUTDOWN }
 Possible run modes of pool. More...
 

Private Attributes

OFMutex m_criticalSection
 Mutex that guards the list of busy and idle workers.
 
OFList< DcmBaseSCPWorker * > m_workersBusy
 List of all workers running a connection.
 
OFList< DcmBaseSCPWorker * > m_workersIdle
 List of all workers being idle, i.e. not running a connection.
 
DcmSCPConfig m_cfg
 SCP configuration to be used by pool and all workers.
 
Uint16 m_maxWorkers
 Maximum number of workers that can exist at a time. More...
 
runmode m_runMode
 Current run mode of pool.
 

Detailed Description

Base class for implementing an SCP pool with one thread listening for incoming TCP/IP connections and spawning a number of SCP worker threads that handle the incoming DICOM association on that connection.

This base class is abstract.

Member Enumeration Documentation

◆ runmode

Possible run modes of pool.

Enumerator
LISTEN 

Listen for new connections.

STOP 

Reserved for later use.

SHUTDOWN 

Shutting down worker threads.

Constructor & Destructor Documentation

◆ DcmBaseSCPPool()

DcmBaseSCPPool::DcmBaseSCPPool ( )
protected

Constructor.

Initializes internal member variables.

Member Function Documentation

◆ createSCPWorker()

virtual DcmBaseSCPWorker* DcmBaseSCPPool::createSCPWorker ( )
protectedpure virtual

Create SCP worker.

Returns
The worker created

◆ dropAndDestroyAssociation()

virtual void DcmBaseSCPPool::dropAndDestroyAssociation ( T_ASC_Association assoc)
protectedvirtual

Drops association and clears internal structures to free memory.

Parameters
assocThe association to free

◆ getConfig()

virtual DcmSCPConfig& DcmBaseSCPPool::getConfig ( )
virtual

Return handle to the SCP configuration that is used to configure how to handle incoming associations.

For the pool, e.g. by providing settings for TCP connection timeout, and for the workers, e.g. by configuration presentation contexts and the like.

Returns
The SCP configuration(s).

◆ getMaxThreads()

virtual Uint16 DcmBaseSCPPool::getMaxThreads ( )
virtual

Get number of maximum permitted connections, i.e. threads/workers.

Returns
Number of threads permitted to exist within pool.

◆ listen()

virtual OFCondition DcmBaseSCPPool::listen ( )
virtual

Listen for incoming association requests.

For each incoming request, a new thread is started if number of maximum threads is not reached yet.

Returns
DUL_NOASSOCIATIONREQUEST if no connection is requested during timeout. Returns other error code if serious error occurs during listening. Will not return EC_Normal since listens forever if no timeout occurs.

◆ notifyThreadExit()

void DcmBaseSCPPool::notifyThreadExit ( DcmBaseSCPWorker thread,
OFCondition  result 
)
protected

Used by thread to tell pool it has terminated.

Parameters
threadThe thread that is calling this function and is about to exit.
resultThe final result of the thread.

◆ numThreads()

virtual size_t DcmBaseSCPPool::numThreads ( const OFBool  onlyBusy)
virtual

Get number of currently active connections.

Parameters
onlyBusyReturn only number of those workers that are busy with a connection and not idle, if OFTrue.
Returns
Number of connections currently handled within pool

◆ rejectAssociation()

void DcmBaseSCPPool::rejectAssociation ( T_ASC_Association assoc,
const T_ASC_RejectParametersReason &  reason 
)
protected

Reject association using the given reason, e.g. because maximum number of connections is currently already served.

Parameters
assocThe association to reject
reasonThe rejection reason

◆ runAssociation()

OFCondition DcmBaseSCPPool::runAssociation ( T_ASC_Association assoc,
const DcmSharedSCPConfig sharedConfig 
)
protected

Try to find worker to run the association.

If worker could be found, a side effect is that assoc is set to NULL.

Parameters
assocThe association to be run. Must be not NULL.
sharedConfigA DcmSharedSCPConfig object to be used by the worker.
Returns
EC_Normal if worker could be found and runs the association, an error code otherwise.

◆ setMaxThreads()

virtual void DcmBaseSCPPool::setMaxThreads ( const Uint16  maxWorkers)
virtual

Set the number of maximum permitted connections, i.e. threads/workers.

Parameters
maxWorkersNumber of threads permitted to exist within pool.

Member Data Documentation

◆ m_maxWorkers

Uint16 DcmBaseSCPPool::m_maxWorkers
private

Maximum number of workers that can exist at a time.

Thus limits the maximum number of connections for the pool since every worker serves one connection at a time.


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


Generated on Mon Jul 17 2017 for DCMTK Version 3.6.2 by Doxygen 1.8.13