|
DCMTK Version 3.7.1
OFFIS DICOM Toolkit
|
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. | |
| 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 () |
| Request the pool to stop listening for incoming requests. | |
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 | notifyWorkerDone (DcmBaseSCPWorker *thread, OFCondition result) |
| Used by thread to tell pool it has terminated. | |
| virtual OFCondition | initializeNetwork (T_ASC_Network **network) |
| Initialize network, i.e. | |
Private Types | |
| enum | runmode { LISTEN , STOP , SHUTDOWN } |
| Possible run modes of pool. More... | |
Private Member Functions | |
| void | finishListening () |
| Set m_runMode to SHUTDOWN on return from listen function. | |
| void | reapFinishedWorkers () |
| Join and delete all worker threads that have finished handling their association. | |
| runmode | getRunMode () |
| Thread-safe read of the current run mode, guarded by m_criticalSection. | |
| void | setRunMode (const runmode mode) |
| Thread-safe update of the current run mode, guarded by m_criticalSection. | |
Private Attributes | |
| OFMutex | m_criticalSection |
| Mutex that guards the worker lists, the maximum number of workers and the run mode. | |
| OFList< DcmBaseSCPWorker * > | m_workersBusy |
| List of all workers running a connection. | |
| OFList< DcmBaseSCPWorker * > | m_workersIdle |
| List of all workers that have finished their connection and are waiting to be joined and deleted (see reapFinishedWorkers()). | |
| 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. | |
| volatile runmode | m_runMode |
| Current run mode of pool. | |
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.
|
private |
|
virtual |
Virtual destructor, frees internal memory.
Note that the destructor blocks until listen() has returned (see stopAfterCurrentAssociations()) and all worker threads have finished their associations.
|
protected |
Constructor.
Initializes internal member variables.
Referenced by DcmBaseSCPPool::DcmBaseSCPWorker::DcmBaseSCPWorker().
|
protectedpure virtual |
Create SCP worker.
Implemented in DcmSCPPool< SCP, SCPPool, BaseSCPWorker >.
|
protectedvirtual |
Drops association and clears internal structures to free memory.
| assoc | The association to free |
|
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.
|
virtual |
Get number of maximum permitted connections, i.e. threads/workers.
|
private |
Thread-safe read of the current run mode, guarded by m_criticalSection.
|
protectedvirtual |
Initialize network, i.e.
create an instance of T_ASC_Network and set transport layer if it is enabled.
| network | The T_ASC_Network pointer to create the instance |
|
virtual |
Listen for incoming association requests.
For each incoming request, a new worker thread is started if the number of maximum threads is not reached yet, otherwise the request is refused ("local limit exceeded"). Errors while handling a single connection request (e.g. temporary resource shortage when creating a worker thread) lead to a refusal of that request ("temporary congestion") but do not stop the server. The method only returns after stopAfterCurrentAssociations() has been called (or if network initialization failed). Note that with the default blocking connection mode a stop request only takes effect when the next connection request arrives; use non-blocking mode (see DcmSCPConfig::setConnectionBlockingMode()) together with a connection timeout for a pool that should be stoppable at any time.
|
protected |
Used by thread to tell pool it has terminated.
| thread | The thread that is calling this function and is about to exit. |
| result | The final result of the thread. |
|
virtual |
Get number of currently active connections.
| onlyBusy | Return only number of those workers that are busy with a connection and not idle, if OFTrue. |
|
private |
Join and delete all worker threads that have finished handling their association.
Called regularly from the listen loop and from the destructor, so that resources of terminated threads are reclaimed while the pool keeps running.
|
protected |
Reject association using the given reason, e.g. because maximum number of connections is currently already served.
| assoc | The association to reject |
| reason | The rejection reason |
|
protected |
Try to find worker to run the association.
If worker could be found, a side effect is that assoc is set to NULL.
| assoc | The association to be run. Must be not NULL. |
| sharedConfig | A DcmSharedSCPConfig object to be used by the worker. |
|
virtual |
Set the number of maximum permitted connections, i.e. threads/workers.
| maxWorkers | Number of threads permitted to exist within pool. |
|
private |
Thread-safe update of the current run mode, guarded by m_criticalSection.
| mode | the new run mode to set. |
|
virtual |
Request the pool to stop listening for incoming requests.
The listen loop will exit when the current call waiting for a connection request returns (see listen() about blocking vs. non-blocking mode). Workers that are still handling an association finish their work; the destructor waits for all of them to terminate.
|
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.