Esempio n. 1
0
VSIFileManager *VSIFileManager::Get()

{
    static volatile GPtrDiff_t nConstructerPID = 0;
    if( poManager != NULL )
    {
        if( nConstructerPID != 0 )
        {
            GPtrDiff_t nCurrentPID = static_cast<GPtrDiff_t>(CPLGetPID());
            if( nConstructerPID != nCurrentPID )
            {
                {
                    CPLMutexHolder oHolder( &hVSIFileManagerMutex );
                }
                if ( nConstructerPID != 0 )
                {
                    VSIDebug1( "nConstructerPID != 0: %d", nConstructerPID);
                    assert(false);
                }
            }
        }
        return poManager;
    }

    CPLMutexHolder oHolder2( &hVSIFileManagerMutex );
    if( poManager == NULL )
    {
        nConstructerPID = static_cast<GPtrDiff_t>(CPLGetPID());
#ifdef DEBUG_VERBOSE
        printf("Thread %d: VSIFileManager in construction\n", nConstructerPID);
#endif
        poManager = new VSIFileManager;
        VSIInstallLargeFileHandler();
        VSIInstallSubFileHandler();
        VSIInstallMemFileHandler();
#ifdef HAVE_LIBZ
        VSIInstallGZipFileHandler();
        VSIInstallZipFileHandler();
#endif
#ifdef HAVE_CURL
        VSIInstallCurlFileHandler();
        VSIInstallCurlStreamingFileHandler();
        VSIInstallS3FileHandler();
        VSIInstallS3StreamingFileHandler();
#endif
        VSIInstallStdinHandler();
        VSIInstallStdoutHandler();
        VSIInstallSparseFileHandler();
        VSIInstallTarFileHandler();
        VSIInstallCryptFileHandler();

        //printf("Thread %d: VSIFileManager construction finished\n", nConstructerPID);
        nConstructerPID = 0;
    }

    return poManager;
}
Esempio n. 2
0
VSIFileManager *VSIFileManager::Get()

{
    static volatile int nConstructerPID = 0;
    if( poManager != NULL )
    {
        if( nConstructerPID != 0 )
        {
            int nCurrentPID = (int)CPLGetPID();
            if( nConstructerPID != nCurrentPID )
            {
                //printf("Thread %d: Waiting for VSIFileManager to be finished by other thread.\n", nCurrentPID);
                {
                    CPLMutexHolder oHolder( &hVSIFileManagerMutex );
                }
                //printf("Thread %d: End of wait for VSIFileManager construction to be finished\n", nCurrentPID);
                CPLAssert(nConstructerPID == 0);
            }
        }
        return poManager;
    }

    CPLMutexHolder oHolder2( &hVSIFileManagerMutex );
    if( poManager == NULL )
    {
        nConstructerPID = (int)CPLGetPID();
        //printf("Thread %d: VSIFileManager in construction\n", nConstructerPID);
        poManager = new VSIFileManager;
        VSIInstallLargeFileHandler();
        VSIInstallSubFileHandler();
        VSIInstallMemFileHandler();
#ifdef HAVE_LIBZ
        VSIInstallGZipFileHandler();
        VSIInstallZipFileHandler();
#endif
#ifdef HAVE_CURL
        VSIInstallCurlFileHandler();
        VSIInstallCurlStreamingFileHandler();
#endif
        VSIInstallStdinHandler();
        VSIInstallStdoutHandler();
        VSIInstallSparseFileHandler();
        VSIInstallTarFileHandler();
        //printf("Thread %d: VSIFileManager construction finished\n", nConstructerPID);
        nConstructerPID = 0;
    }
    
    return poManager;
}