You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ne...@apache.org on 2003/10/09 15:54:25 UTC
cvs commit: xml-xerces/c/src/xercesc/internal XMLGrammarPoolImpl.cpp XMLGrammarPoolImpl.hpp
neilg 2003/10/09 06:54:25
Modified: c/src/xercesc/internal XMLGrammarPoolImpl.cpp
XMLGrammarPoolImpl.hpp
Log:
modify grammar pool implementation to that, once locked, a thread-safe StringPool is used
Revision Changes Path
1.6 +19 -3 xml-xerces/c/src/xercesc/internal/XMLGrammarPoolImpl.cpp
Index: XMLGrammarPoolImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/XMLGrammarPoolImpl.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XMLGrammarPoolImpl.cpp 16 Sep 2003 18:30:54 -0000 1.5
+++ XMLGrammarPoolImpl.cpp 9 Oct 2003 13:54:25 -0000 1.6
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.6 2003/10/09 13:54:25 neilg
+ * modify grammar pool implementation to that, once locked, a thread-safe StringPool is used
+ *
* Revision 1.5 2003/09/16 18:30:54 neilg
* make Grammar pool be responsible for creating and owning URI string pools. This is one more step towards having grammars be independent of the parsers involved in their creation
*
@@ -96,12 +99,16 @@
{
delete fGrammarRegistry;
delete fStringPool;
+ if(fSynchronizedStringPool)
+ delete fSynchronizedStringPool;
}
XMLGrammarPoolImpl::XMLGrammarPoolImpl(MemoryManager* const memMgr)
:XMLGrammarPool(memMgr)
,fGrammarRegistry(0)
,fStringPool(0)
+,fSynchronizedStringPool(0)
+,fLocked(false)
{
fGrammarRegistry = new (memMgr) RefHashTableOf<Grammar>(29, true, memMgr);
fStringPool = new (memMgr) XMLStringPool(109, memMgr);
@@ -157,12 +164,19 @@
void XMLGrammarPoolImpl::lockPool()
{
- //This implementation does NOT provide thread safety mechanism
+ fLocked = true;
+ if(!fSynchronizedStringPool)
+ {
+ MemoryManager *memMgr = getMemoryManager();
+ fSynchronizedStringPool = new (memMgr) XMLSynchronizedStringPool(fStringPool, 109, memMgr);
+ }
}
void XMLGrammarPoolImpl::unlockPool()
{
- //This implementation does NOT provide thread safety mechanism
+ fLocked = false;
+ if(fSynchronizedStringPool)
+ fSynchronizedStringPool->flushAll();
}
// -----------------------------------------------------------------------
@@ -190,6 +204,8 @@
inline XMLStringPool *XMLGrammarPoolImpl::getURIStringPool()
{
+ if(fLocked)
+ return fSynchronizedStringPool;
return fStringPool;
}
1.6 +12 -1 xml-xerces/c/src/xercesc/internal/XMLGrammarPoolImpl.hpp
Index: XMLGrammarPoolImpl.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/XMLGrammarPoolImpl.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XMLGrammarPoolImpl.hpp 16 Sep 2003 18:30:54 -0000 1.5
+++ XMLGrammarPoolImpl.hpp 9 Oct 2003 13:54:25 -0000 1.6
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.6 2003/10/09 13:54:25 neilg
+ * modify grammar pool implementation to that, once locked, a thread-safe StringPool is used
+ *
* Revision 1.5 2003/09/16 18:30:54 neilg
* make Grammar pool be responsible for creating and owning URI string pools. This is one more step towards having grammars be independent of the parsers involved in their creation
*
@@ -82,6 +85,7 @@
#include <xercesc/framework/XMLGrammarPool.hpp>
#include <xercesc/util/RefHashTableOf.hpp>
+#include <xercesc/util/SynchronizedStringPool.hpp>
XERCES_CPP_NAMESPACE_BEGIN
@@ -226,10 +230,17 @@
// container
// fStringPool
// grammars need a string pool for URI -> int mappings
+ // fSynchronizedStringPool
+ // When the grammar pool is locked, provide a string pool
+ // that can be updated in a thread-safe manner.
+ // fLocked
+ // whether the pool has been locked
//
// -----------------------------------------------------------------------
RefHashTableOf<Grammar>* fGrammarRegistry;
XMLStringPool * fStringPool;
+ XMLSynchronizedStringPool * fSynchronizedStringPool;
+ bool fLocked;
};
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org