projects
/
shibboleth
/
cpp-xmltooling.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7330830
)
Adjust Lock API
author
Scott Cantor
<cantor.2@osu.edu>
Sat, 24 Dec 2011 21:45:21 +0000
(21:45 +0000)
committer
Scott Cantor
<cantor.2@osu.edu>
Sat, 24 Dec 2011 21:45:21 +0000
(21:45 +0000)
xmltooling/XMLToolingConfig.cpp
patch
|
blob
|
history
xmltooling/internal.h
patch
|
blob
|
history
xmltooling/util/ParserPool.cpp
patch
|
blob
|
history
xmltooling/util/Threads.h
patch
|
blob
|
history
diff --git
a/xmltooling/XMLToolingConfig.cpp
b/xmltooling/XMLToolingConfig.cpp
index
6760d9e
..
bd7fbcb
100644
(file)
--- a/
xmltooling/XMLToolingConfig.cpp
+++ b/
xmltooling/XMLToolingConfig.cpp
@@
-294,7
+294,6
@@
XMLToolingInternalConfig::XMLToolingInternalConfig() :
XMLToolingInternalConfig::~XMLToolingInternalConfig()
{
XMLToolingInternalConfig::~XMLToolingInternalConfig()
{
- delete m_lock;
}
bool XMLToolingInternalConfig::log_config(const char* config)
}
bool XMLToolingInternalConfig::log_config(const char* config)
diff --git
a/xmltooling/internal.h
b/xmltooling/internal.h
index
c486b10
..
bf879f3
100644
(file)
--- a/
xmltooling/internal.h
+++ b/
xmltooling/internal.h
@@
-132,7
+132,7
@@
namespace xmltooling {
private:
int m_initCount;
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;
std::map<std::string,Mutex*> m_namedLocks;
std::vector<void*> m_libhandles;
ParserPool* m_parserPool;
diff --git
a/xmltooling/util/ParserPool.cpp
b/xmltooling/util/ParserPool.cpp
index
ca155ca
..
42fc535
100644
(file)
--- a/
xmltooling/util/ParserPool.cpp
+++ b/
xmltooling/util/ParserPool.cpp
@@
-229,7
+229,7
@@
bool ParserPool::loadSchema(const XMLCh* nsURI, const XMLCh* pathname)
return false;
}
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));
m_schemaLocMap[nsURI]=pathname;
m_schemaLocations.erase();
for_each(m_schemaLocMap.begin(), m_schemaLocMap.end(), doubleit<xstring>(m_schemaLocations,chSpace));
@@
-302,7
+302,7
@@
bool ParserPool::loadCatalog(const XMLCh* pathname)
// Fetch all the <system> elements.
DOMNodeList* mappings=root->getElementsByTagNameNS(CATALOG_NS,system);
// 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);
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::createBuilder()
DOMLSParser* ParserPool::checkoutBuilder()
{
DOMLSParser* ParserPool::checkoutBuilder()
{
- Lock lock(m_lock
.get()
);
+ Lock lock(m_lock);
if (m_pool.empty()) {
DOMLSParser* builder=createBuilder();
return builder;
if (m_pool.empty()) {
DOMLSParser* builder=createBuilder();
return builder;
@@
-415,7
+415,7
@@
DOMLSParser* ParserPool::checkoutBuilder()
void ParserPool::checkinBuilder(DOMLSParser* builder)
{
if (builder) {
void ParserPool::checkinBuilder(DOMLSParser* builder)
{
if (builder) {
- Lock lock(m_lock
.get()
);
+ Lock lock(m_lock);
m_pool.push(builder);
}
}
m_pool.push(builder);
}
}
@@
-447,7
+447,7
@@
DOMBuilder* ParserPool::createBuilder()
DOMBuilder* ParserPool::checkoutBuilder()
{
DOMBuilder* ParserPool::checkoutBuilder()
{
- Lock lock(m_lock
.get()
);
+ Lock lock(m_lock);
if (m_pool.empty()) {
DOMBuilder* builder=createBuilder();
return builder;
if (m_pool.empty()) {
DOMBuilder* builder=createBuilder();
return builder;
@@
-462,7
+462,7
@@
DOMBuilder* ParserPool::checkoutBuilder()
void ParserPool::checkinBuilder(DOMBuilder* builder)
{
if (builder) {
void ParserPool::checkinBuilder(DOMBuilder* builder)
{
if (builder) {
- Lock lock(m_lock
.get()
);
+ Lock lock(m_lock);
m_pool.push(builder);
}
}
m_pool.push(builder);
}
}
diff --git
a/xmltooling/util/Threads.h
b/xmltooling/util/Threads.h
index
959031d
..
5269763
100644
(file)
--- a/
xmltooling/util/Threads.h
+++ b/
xmltooling/util/Threads.h
@@
-29,6
+29,7
@@
#include <xmltooling/exceptions.h>
#include <xmltooling/exceptions.h>
+#include <memory>
#include <signal.h>
namespace xmltooling
#include <signal.h>
namespace xmltooling
@@
-305,6
+306,16
@@
namespace xmltooling
}
/**
}
/**
+ * 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() {
* Unlocks the wrapped mutex.
*/
~Lock() {
@@
-334,6
+345,17
@@
namespace xmltooling
}
/**
}
/**
+ * 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() {
* Unlocks the wrapped shared lock.
*/
~SharedLock() {