Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:32:08

0001 #include "Utilities/Xerces/interface/Xerces.h"
0002 #include <xercesc/util/PlatformUtils.hpp>
0003 #include <mutex>
0004 #include <thread>
0005 
0006 XERCES_CPP_NAMESPACE_USE
0007 
0008 namespace cms {
0009   namespace concurrency {
0010     namespace {
0011       std::mutex g_xerces_mutex;
0012     }
0013     // We need to make sure these serialized are only called by one
0014     // thread at the time.  Until the first Init succeeds the other threads
0015     // should not be allowed to proceed.  We also do not want two different
0016     // threads calling Init and Finalize at the same time. We therefore simply
0017     // use a global mutex to serialize everything.
0018     void xercesInitialize() {
0019       std::unique_lock<std::mutex> l(g_xerces_mutex);
0020       XMLPlatformUtils::Initialize();
0021     }
0022 
0023     void xercesTerminate() {
0024       std::unique_lock<std::mutex> l(g_xerces_mutex);
0025       XMLPlatformUtils::Terminate();
0026     }
0027   }  // namespace concurrency
0028 }  // namespace cms