[cpp-xmltooling COMMIT] in /branches/REL_1/xmltooling: XMLToolingConfig.cpp internal.h util/ParserPool.cpp util/Threa...
noreply at shibboleth.net
noreply at shibboleth.net
Sat Dec 24 21:45:22 GMT 2011
Author: scantor
Date: Sat Dec 24 21:45:21 2011
New Revision: 947
URL: http://svn.shibboleth.net/view/cpp-xmltooling?rev=947&view=rev
Log:
Adjust Lock API
Modified:
branches/REL_1/xmltooling/XMLToolingConfig.cpp
branches/REL_1/xmltooling/internal.h
branches/REL_1/xmltooling/util/ParserPool.cpp
branches/REL_1/xmltooling/util/Threads.h
Modified: branches/REL_1/xmltooling/XMLToolingConfig.cpp
URL: http://svn.shibboleth.net/view/cpp-xmltooling/branches/REL_1/xmltooling/XMLToolingConfig.cpp?rev=947&r1=946&r2=947&view=diff
==============================================================================
--- branches/REL_1/xmltooling/XMLToolingConfig.cpp (original)
+++ branches/REL_1/xmltooling/XMLToolingConfig.cpp Sat Dec 24 21:45:21 2011
@@ -294,7 +294,6 @@
XMLToolingInternalConfig::~XMLToolingInternalConfig()
{
- delete m_lock;
}
bool XMLToolingInternalConfig::log_config(const char* config)
Modified: branches/REL_1/xmltooling/internal.h
URL: http://svn.shibboleth.net/view/cpp-xmltooling/branches/REL_1/xmltooling/internal.h?rev=947&r1=946&r2=947&view=diff
==============================================================================
--- branches/REL_1/xmltooling/internal.h (original)
+++ branches/REL_1/xmltooling/internal.h Sat Dec 24 21:45:21 2011
@@ -132,7 +132,7 @@
private:
int m_initCount;
- Mutex* m_lock;
+ std::auto_ptr<Mutex> m_lock;
std::map<std::string,Mutex*> m_namedLocks;
std::vector<void*> m_libhandles;
ParserPool* m_parserPool;
Modified: branches/REL_1/xmltooling/util/ParserPool.cpp
URL: http://svn.shibboleth.net/view/cpp-xmltooling/branches/REL_1/xmltooling/util/ParserPool.cpp?rev=947&r1=946&r2=947&view=diff
==============================================================================
--- branches/REL_1/xmltooling/util/ParserPool.cpp (original)
+++ branches/REL_1/xmltooling/util/ParserPool.cpp Sat Dec 24 21:45:21 2011
@@ -229,7 +229,7 @@
return false;
}
- Lock lock(m_lock.get());
+ Lock lock(m_lock);
m_schemaLocMap[nsURI]=pathname;
m_schemaLocations.erase();
for_each(m_schemaLocMap.begin(), m_schemaLocMap.end(), doubleit<xstring>(m_schemaLocations,chSpace));
@@ -302,7 +302,7 @@
// Fetch all the <system> elements.
DOMNodeList* mappings=root->getElementsByTagNameNS(CATALOG_NS,system);
- Lock lock(m_lock.get());
+ Lock lock(m_lock);
for (XMLSize_t i=0; i<mappings->getLength(); i++) {
root=static_cast<DOMElement*>(mappings->item(i));
const XMLCh* from=root->getAttributeNS(nullptr,systemId);
@@ -400,7 +400,7 @@
DOMLSParser* ParserPool::checkoutBuilder()
{
- Lock lock(m_lock.get());
+ Lock lock(m_lock);
if (m_pool.empty()) {
DOMLSParser* builder=createBuilder();
return builder;
@@ -415,7 +415,7 @@
void ParserPool::checkinBuilder(DOMLSParser* builder)
{
if (builder) {
- Lock lock(m_lock.get());
+ Lock lock(m_lock);
m_pool.push(builder);
}
}
@@ -447,7 +447,7 @@
DOMBuilder* ParserPool::checkoutBuilder()
{
- Lock lock(m_lock.get());
+ Lock lock(m_lock);
if (m_pool.empty()) {
DOMBuilder* builder=createBuilder();
return builder;
@@ -462,7 +462,7 @@
void ParserPool::checkinBuilder(DOMBuilder* builder)
{
if (builder) {
- Lock lock(m_lock.get());
+ Lock lock(m_lock);
m_pool.push(builder);
}
}
Modified: branches/REL_1/xmltooling/util/Threads.h
URL: http://svn.shibboleth.net/view/cpp-xmltooling/branches/REL_1/xmltooling/util/Threads.h?rev=947&r1=946&r2=947&view=diff
==============================================================================
--- branches/REL_1/xmltooling/util/Threads.h (original)
+++ branches/REL_1/xmltooling/util/Threads.h Sat Dec 24 21:45:21 2011
@@ -29,6 +29,7 @@
#include <xmltooling/exceptions.h>
+#include <memory>
#include <signal.h>
namespace xmltooling
@@ -305,6 +306,16 @@
}
/**
+ * Locks and wraps the designated mutex.
+ *
+ * @param mtx mutex to lock
+ */
+ Lock(std::auto_ptr<Mutex>& mtx) : mutex(mtx.get()) {
+ if (mutex)
+ mutex->lock();
+ }
+
+ /**
* Unlocks the wrapped mutex.
*/
~Lock() {
@@ -334,6 +345,17 @@
}
/**
+ * Locks and wraps the designated shared lock.
+ *
+ * @param lock lock to acquire
+ * @param lockit true if the lock should be acquired here, false if already acquired
+ */
+ SharedLock(std::auto_ptr<RWLock>& lock, bool lockit=true) : rwlock(lock.get()) {
+ if (rwlock && lockit)
+ rwlock->rdlock();
+ }
+
+ /**
* Unlocks the wrapped shared lock.
*/
~SharedLock() {
More information about the commits
mailing list