Changeset 13466

Show
Ignore:
Timestamp:
12/31/07 09:12:14 (6 months ago)
Author:
warmerdam
Message:

document OGRCleanupAll() and OGRSFDriverRegistrar more clearly

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/gdal/ogr/ogrsf_frmts/generic/ogrsfdriverregistrar.cpp

    r12063 r13466  
    4343/*                         OGRSFDriverRegistrar                         */ 
    4444/************************************************************************/ 
     45 
     46/** 
     47 * Constructor 
     48 * 
     49 * Normally the driver registrar is constucted by the  
     50 * OGRSFDriverRegistrar::GetRegistrar() accessor which ensures singleton 
     51 * status.   
     52 */ 
    4553 
    4654OGRSFDriverRegistrar::OGRSFDriverRegistrar() 
     
    106114/************************************************************************/ 
    107115 
     116/** 
     117 * Cleanup all OGR related resources.  
     118 * 
     119 * This function will destroy the OGRSFDriverRegistrar along with all registered 
     120 * drivers, and then cleanup long lived OSR (OGRSpatialReference) and CPL 
     121 * resources.  This may be called in an application when OGR services are 
     122 * no longer needed.  It is not normally required, but by freeing all 
     123 * dynamically allocated memory it can make memory leak testing easier. 
     124 *  
     125 * In addition to destroying the OGRDriverRegistrar, this function also calls: 
     126 * - OSRCleanup() 
     127 * - CPLFinderClean() 
     128 * - VSICleanupFileManager() 
     129 * - CPLFreeConfig() 
     130 * - CPLCleanupTLS() 
     131 */ 
    108132void OGRCleanupAll() 
    109133 
    110134{ 
    111     CPLMutexHolderD( &hDRMutex ); 
    112  
    113     if( poRegistrar != NULL ) 
    114         delete poRegistrar; 
    115     OSRCleanup(); 
     135    { 
     136        // We don't want to hold the mutex while CPL level mutex services 
     137        // are being destroyed ... just long enough to avoid conflict while 
     138        // cleaning up OGR and OSR services. 
     139        CPLMutexHolderD( &hDRMutex ); 
     140     
     141        if( poRegistrar != NULL ) 
     142            delete poRegistrar; 
     143        OSRCleanup(); 
     144    } 
     145 
    116146    CPLFinderClean(); 
    117147    VSICleanupFileManager(); 
     
    124154/*                            GetRegistrar()                            */ 
    125155/************************************************************************/ 
     156 
     157/** 
     158 * Fetch registrar. 
     159 * 
     160 * This static method should be used to fetch the singleton  
     161 * registrar.  It will create a registrar if there is not already 
     162 * one in existance. 
     163 * 
     164 * @return the current driver registrar. 
     165 */ 
    126166 
    127167OGRSFDriverRegistrar *OGRSFDriverRegistrar::GetRegistrar() 
  • trunk/gdal/ogr/ogrsf_frmts/ogrsf_frmts.h

    r12731 r13466  
    255255 
    256256/** 
    257  * Singleton manager for drivers. 
    258  * 
     257 * Singleton manager for OGRSFDriver instances that will be used to try 
     258 * and open datasources.  Normally the registrar is populated with  
     259 * standard drivers using the OGRRegisterAll() function and does not need 
     260 * to be directly accessed.  The driver registrar and all registered drivers 
     261 * may be cleaned up on shutdown using OGRCleanupAll(). 
    259262 */ 
    260263