DCMTK Version 3.6.9 OFFIS DICOM Toolkit

Loading...
Searching...
No Matches
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...

Inheritance diagram for DcmBaseSCPPool:

## 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.
virtual Uint16 | getMaxThreads ()
| Get number of maximum permitted connections, i.e. threads/workers.
virtual size_t | numThreads (const OFBool onlyBusy)
| Get number of currently active connections.
virtual OFCondition | listen ()
| Listen for incoming association requests.
virtual DcmSCPConfig & | getConfig ()
| Return handle to the SCP configuration that is used to configure how to handle incoming associations.
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.
virtual DcmBaseSCPWorker * | createSCPWorker ()=0
| Create SCP worker.
OFCondition | runAssociation (T_ASC_Association *assoc, const DcmSharedSCPConfig &sharedConfig)
| Try to find worker to run the association.
virtual void | dropAndDestroyAssociation (T_ASC_Association *assoc)
| Drops association and clears internal structures to free memory.
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.
void | notifyThreadExit (DcmBaseSCPWorker *thread, OFCondition result)
| Used by thread to tell pool it has terminated.
virtual OFCondition | initializeNework (T_ASC_Network **network)
| Initialize network, i.e.

## 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.
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.

Remarks
  This class is only available if DCMTK is compiled with thread support enabled.

## Member Enumeration Documentation

## ◆ runmode

enum DcmBaseSCPPool::runmode
| private

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.

Referenced by DcmBaseSCPPool::DcmBaseSCPWorker::DcmBaseSCPWorker().

## Member Function Documentation

## ◆ createSCPWorker()

virtual DcmBaseSCPWorker * DcmBaseSCPPool::createSCPWorker | ( |  | ) |
| protected pure virtual

Create SCP worker.

Returns
  The worker created

Implemented in DcmSCPPool< SCP, SCPPool, BaseSCPWorker >.

## ◆ dropAndDestroyAssociation()

virtual void DcmBaseSCPPool::dropAndDestroyAssociation | ( | T_ASC_Association * | assoc | ) |
| protected virtual

Drops association and clears internal structures to free memory.

Parameters

  assoc | The 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.

## ◆ initializeNework()

virtual OFCondition DcmBaseSCPPool::initializeNework | ( | T_ASC_Network ** | network | ) |
| protected virtual

Initialize network, i.e.

create an instance of T_ASC_Network and set transport layer if it is enabled.

Parameters

  network | The T_ASC_Network pointer to create the instance

Returns
  EC_Normal if there were no errors during initialization.

## ◆ 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

  thread | The thread that is calling this function and is about to exit.
  result | The final result of the thread.

## ◆ numThreads()

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

Get number of currently active connections.

Parameters

  onlyBusy | Return 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

  assoc | The association to reject
  reason | The 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

  assoc | The association to be run. Must be not NULL.
  sharedConfig | A 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

  maxWorkers | Number 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:

- dcmnet/include/dcmtk/dcmnet/scppool.h

Generated on Sat Mar 1 2025 for DCMTK Version 3.6.9 by Doxygen 1.13.2