Cache: Use consistent naming

- snake_case
- member variables prefixed with m_
- static member variables prefixed with s_
- where prefixes are used (z,p,s), the following character
  is capitalized
This commit is contained in:
Johan Wikman
2017-01-31 12:50:27 +02:00
parent f2da434b56
commit 4ef4cb490b
14 changed files with 298 additions and 298 deletions

View File

@ -26,7 +26,7 @@ CacheMT::CacheMT(const std::string& name,
Storage* pStorage) Storage* pStorage)
: CacheSimple(name, pConfig, sRules, sFactory, pStorage) : CacheSimple(name, pConfig, sRules, sFactory, pStorage)
{ {
spinlock_init(&m_lockPending); spinlock_init(&m_lock_pending);
MXS_NOTICE("Created multi threaded cache."); MXS_NOTICE("Created multi threaded cache.");
} }
@ -57,21 +57,21 @@ CacheMT* CacheMT::Create(const std::string& name, const CACHE_CONFIG* pConfig)
json_t* CacheMT::get_info(uint32_t flags) const json_t* CacheMT::get_info(uint32_t flags) const
{ {
SpinLockGuard guard(m_lockPending); SpinLockGuard guard(m_lock_pending);
return CacheSimple::do_get_info(flags); return CacheSimple::do_get_info(flags);
} }
bool CacheMT::must_refresh(const CACHE_KEY& key, const CacheFilterSession* pSession) bool CacheMT::must_refresh(const CACHE_KEY& key, const CacheFilterSession* pSession)
{ {
SpinLockGuard guard(m_lockPending); SpinLockGuard guard(m_lock_pending);
return do_must_refresh(key, pSession); return do_must_refresh(key, pSession);
} }
void CacheMT::refreshed(const CACHE_KEY& key, const CacheFilterSession* pSession) void CacheMT::refreshed(const CACHE_KEY& key, const CacheFilterSession* pSession)
{ {
SpinLockGuard guard(m_lockPending); SpinLockGuard guard(m_lock_pending);
do_refreshed(key, pSession); do_refreshed(key, pSession);
} }

View File

@ -46,5 +46,5 @@ private:
CacheMT& operator = (const CacheMT&); CacheMT& operator = (const CacheMT&);
private: private:
mutable SPINLOCK m_lockPending; // Lock used for protecting 'pending'. mutable SPINLOCK m_lock_pending; // Lock used for protecting 'pending'.
}; };

View File

@ -122,9 +122,9 @@ json_t* CachePT::get_info(uint32_t what) const
return pInfo; return pInfo;
} }
cache_result_t CachePT::get_key(const char* zDefaultDb, const GWBUF* pQuery, CACHE_KEY* pKey) const cache_result_t CachePT::get_key(const char* zDefault_db, const GWBUF* pQuery, CACHE_KEY* pKey) const
{ {
return thread_cache().get_key(zDefaultDb, pQuery, pKey); return thread_cache().get_key(zDefault_db, pQuery, pKey);
} }
cache_result_t CachePT::get_value(const CACHE_KEY& key, uint32_t flags, GWBUF** ppValue) const cache_result_t CachePT::get_value(const CACHE_KEY& key, uint32_t flags, GWBUF** ppValue) const

View File

@ -30,7 +30,7 @@ public:
json_t* get_info(uint32_t what) const; json_t* get_info(uint32_t what) const;
cache_result_t get_key(const char* zDefaultDb, const GWBUF* pQuery, CACHE_KEY* pKey) const; cache_result_t get_key(const char* zDefault_db, const GWBUF* pQuery, CACHE_KEY* pKey) const;
cache_result_t get_value(const CACHE_KEY& key, uint32_t flags, GWBUF** ppValue) const; cache_result_t get_value(const CACHE_KEY& key, uint32_t flags, GWBUF** ppValue) const;

View File

@ -14,76 +14,76 @@
#define MXS_MODULE_NAME "cache" #define MXS_MODULE_NAME "cache"
#include "lrustorage.hh" #include "lrustorage.hh"
LRUStorage::LRUStorage(const CACHE_STORAGE_CONFIG& config, Storage* pstorage) LRUStorage::LRUStorage(const CACHE_STORAGE_CONFIG& config, Storage* pStorage)
: config_(config) : m_config(config)
, pstorage_(pstorage) , m_pStorage(pStorage)
, max_count_(config.max_count != 0 ? config.max_count : UINT64_MAX) , m_max_count(config.max_count != 0 ? config.max_count : UINT64_MAX)
, max_size_(config.max_size != 0 ? config.max_size : UINT64_MAX) , m_max_size(config.max_size != 0 ? config.max_size : UINT64_MAX)
, phead_(NULL) , m_pHead(NULL)
, ptail_(NULL) , m_pTail(NULL)
{ {
} }
LRUStorage::~LRUStorage() LRUStorage::~LRUStorage()
{ {
Node* pnode = phead_; Node* pnode = m_pHead;
while (phead_) while (m_pHead)
{ {
free_node(phead_); // Adjusts phead_ free_node(m_pHead); // Adjusts m_pHead
} }
delete pstorage_; delete m_pStorage;
} }
void LRUStorage::get_config(CACHE_STORAGE_CONFIG* pConfig) void LRUStorage::get_config(CACHE_STORAGE_CONFIG* pConfig)
{ {
*pConfig = config_; *pConfig = m_config;
} }
cache_result_t LRUStorage::get_key(const char* zdefault_db, cache_result_t LRUStorage::get_key(const char* zDefault_db,
const GWBUF* pquery, const GWBUF* pQuery,
CACHE_KEY* pkey) const CACHE_KEY* pKey) const
{ {
return pstorage_->get_key(zdefault_db, pquery, pkey); return m_pStorage->get_key(zDefault_db, pQuery, pKey);
} }
cache_result_t LRUStorage::do_get_info(uint32_t what, cache_result_t LRUStorage::do_get_info(uint32_t what,
json_t** ppinfo) const json_t** ppInfo) const
{ {
*ppinfo = json_object(); *ppInfo = json_object();
if (*ppinfo) if (*ppInfo)
{ {
json_t* plru = json_object(); json_t* pLru = json_object();
if (plru) if (pLru)
{ {
stats_.fill(plru); m_stats.fill(pLru);
json_object_set(*ppinfo, "lru", plru); json_object_set(*ppInfo, "lru", pLru);
json_decref(plru); json_decref(pLru);
} }
json_t* pstorage_info; json_t* pStorage_info;
cache_result_t result = pstorage_->get_info(what, &pstorage_info); cache_result_t result = m_pStorage->get_info(what, &pStorage_info);
if (CACHE_RESULT_IS_OK(result)) if (CACHE_RESULT_IS_OK(result))
{ {
json_object_set(*ppinfo, "real_storage", pstorage_info); json_object_set(*ppInfo, "real_storage", pStorage_info);
json_decref(pstorage_info); json_decref(pStorage_info);
} }
} }
return *ppinfo ? CACHE_RESULT_OK : CACHE_RESULT_OUT_OF_RESOURCES; return *ppInfo ? CACHE_RESULT_OK : CACHE_RESULT_OUT_OF_RESOURCES;
} }
cache_result_t LRUStorage::do_get_value(const CACHE_KEY& key, cache_result_t LRUStorage::do_get_value(const CACHE_KEY& key,
uint32_t flags, uint32_t flags,
GWBUF** ppvalue) const GWBUF** ppValue) const
{ {
return access_value(APPROACH_GET, key, flags, ppvalue); return access_value(APPROACH_GET, key, flags, ppValue);
} }
cache_result_t LRUStorage::do_put_value(const CACHE_KEY& key, const GWBUF* pvalue) cache_result_t LRUStorage::do_put_value(const CACHE_KEY& key, const GWBUF* pvalue)
@ -92,43 +92,43 @@ cache_result_t LRUStorage::do_put_value(const CACHE_KEY& key, const GWBUF* pvalu
size_t value_size = GWBUF_LENGTH(pvalue); size_t value_size = GWBUF_LENGTH(pvalue);
Node* pnode = NULL; Node* pNode = NULL;
NodesByKey::iterator i = nodes_by_key_.find(key); NodesByKey::iterator i = m_nodes_by_key.find(key);
bool existed = (i != nodes_by_key_.end()); bool existed = (i != m_nodes_by_key.end());
if (existed) if (existed)
{ {
result = get_existing_node(i, pvalue, &pnode); result = get_existing_node(i, pvalue, &pNode);
} }
else else
{ {
result = get_new_node(key, pvalue, &i, &pnode); result = get_new_node(key, pvalue, &i, &pNode);
} }
if (CACHE_RESULT_IS_OK(result)) if (CACHE_RESULT_IS_OK(result))
{ {
ss_dassert(pnode); ss_dassert(pNode);
result = pstorage_->put_value(key, pvalue); result = m_pStorage->put_value(key, pvalue);
if (CACHE_RESULT_IS_OK(result)) if (CACHE_RESULT_IS_OK(result))
{ {
if (existed) if (existed)
{ {
++stats_.updates; ++m_stats.updates;
ss_dassert(stats_.size >= pnode->size()); ss_dassert(m_stats.size >= pNode->size());
stats_.size -= pnode->size(); m_stats.size -= pNode->size();
} }
else else
{ {
++stats_.items; ++m_stats.items;
} }
pnode->reset(&i->first, value_size); pNode->reset(&i->first, value_size);
stats_.size += pnode->size(); m_stats.size += pNode->size();
move_to_head(pnode); move_to_head(pNode);
} }
else if (!existed) else if (!existed)
{ {
@ -144,23 +144,23 @@ cache_result_t LRUStorage::do_del_value(const CACHE_KEY& key)
{ {
cache_result_t result = CACHE_RESULT_NOT_FOUND; cache_result_t result = CACHE_RESULT_NOT_FOUND;
NodesByKey::iterator i = nodes_by_key_.find(key); NodesByKey::iterator i = m_nodes_by_key.find(key);
bool existed = (i != nodes_by_key_.end()); bool existed = (i != m_nodes_by_key.end());
if (existed) if (existed)
{ {
result = pstorage_->del_value(key); result = m_pStorage->del_value(key);
if (CACHE_RESULT_IS_OK(result) || CACHE_RESULT_IS_NOT_FOUND(result)) if (CACHE_RESULT_IS_OK(result) || CACHE_RESULT_IS_NOT_FOUND(result))
{ {
// If it wasn't found, we'll assume it was because ttl has hit in. // If it wasn't found, we'll assume it was because ttl has hit in.
++stats_.deletes; ++m_stats.deletes;
ss_dassert(stats_.size >= i->second->size()); ss_dassert(m_stats.size >= i->second->size());
ss_dassert(stats_.items > 0); ss_dassert(m_stats.items > 0);
stats_.size -= i->second->size(); m_stats.size -= i->second->size();
--stats_.items; --m_stats.items;
free_node(i); free_node(i);
} }
@ -175,15 +175,15 @@ cache_result_t LRUStorage::do_get_head(CACHE_KEY* pKey, GWBUF** ppValue) const
// Since it's the head it's unlikely to have happened, but we need to loop to // Since it's the head it's unlikely to have happened, but we need to loop to
// cater for the case that ttl has hit in. // cater for the case that ttl has hit in.
while (phead_ && (CACHE_RESULT_IS_NOT_FOUND(result))) while (m_pHead && (CACHE_RESULT_IS_NOT_FOUND(result)))
{ {
ss_dassert(phead_->key()); ss_dassert(m_pHead->key());
result = do_get_value(*phead_->key(), CACHE_FLAGS_INCLUDE_STALE, ppValue); result = do_get_value(*m_pHead->key(), CACHE_FLAGS_INCLUDE_STALE, ppValue);
} }
if (CACHE_RESULT_IS_OK(result)) if (CACHE_RESULT_IS_OK(result))
{ {
*pKey = *phead_->key(); *pKey = *m_pHead->key();
} }
return result; return result;
@ -194,15 +194,15 @@ cache_result_t LRUStorage::do_get_tail(CACHE_KEY* pKey, GWBUF** ppValue) const
cache_result_t result = CACHE_RESULT_NOT_FOUND; cache_result_t result = CACHE_RESULT_NOT_FOUND;
// We need to loop to cater for the case that ttl has hit in. // We need to loop to cater for the case that ttl has hit in.
while (ptail_ && CACHE_RESULT_IS_NOT_FOUND(result)) while (m_pTail && CACHE_RESULT_IS_NOT_FOUND(result))
{ {
ss_dassert(ptail_->key()); ss_dassert(m_pTail->key());
result = peek_value(*ptail_->key(), CACHE_FLAGS_INCLUDE_STALE, ppValue); result = peek_value(*m_pTail->key(), CACHE_FLAGS_INCLUDE_STALE, ppValue);
} }
if (CACHE_RESULT_IS_OK(result)) if (CACHE_RESULT_IS_OK(result))
{ {
*pKey = *ptail_->key(); *pKey = *m_pTail->key();
} }
return result; return result;
@ -210,33 +210,33 @@ cache_result_t LRUStorage::do_get_tail(CACHE_KEY* pKey, GWBUF** ppValue) const
cache_result_t LRUStorage::do_get_size(uint64_t* pSize) const cache_result_t LRUStorage::do_get_size(uint64_t* pSize) const
{ {
*pSize = stats_.size; *pSize = m_stats.size;
return CACHE_RESULT_OK; return CACHE_RESULT_OK;
} }
cache_result_t LRUStorage::do_get_items(uint64_t* pItems) const cache_result_t LRUStorage::do_get_items(uint64_t* pItems) const
{ {
*pItems = stats_.items; *pItems = m_stats.items;
return CACHE_RESULT_OK; return CACHE_RESULT_OK;
} }
cache_result_t LRUStorage::access_value(access_approach_t approach, cache_result_t LRUStorage::access_value(access_approach_t approach,
const CACHE_KEY& key, const CACHE_KEY& key,
uint32_t flags, uint32_t flags,
GWBUF** ppvalue) const GWBUF** ppValue) const
{ {
cache_result_t result = CACHE_RESULT_NOT_FOUND; cache_result_t result = CACHE_RESULT_NOT_FOUND;
NodesByKey::iterator i = nodes_by_key_.find(key); NodesByKey::iterator i = m_nodes_by_key.find(key);
bool existed = (i != nodes_by_key_.end()); bool existed = (i != m_nodes_by_key.end());
if (existed) if (existed)
{ {
result = pstorage_->get_value(key, flags, ppvalue); result = m_pStorage->get_value(key, flags, ppValue);
if (CACHE_RESULT_IS_OK(result)) if (CACHE_RESULT_IS_OK(result))
{ {
++stats_.hits; ++m_stats.hits;
if (approach == APPROACH_GET) if (approach == APPROACH_GET)
{ {
@ -245,7 +245,7 @@ cache_result_t LRUStorage::access_value(access_approach_t approach,
} }
else if (CACHE_RESULT_IS_NOT_FOUND(result)) else if (CACHE_RESULT_IS_NOT_FOUND(result))
{ {
++stats_.misses; ++m_stats.misses;
if (!CACHE_RESULT_IS_STALE(result)) if (!CACHE_RESULT_IS_STALE(result))
{ {
@ -256,7 +256,7 @@ cache_result_t LRUStorage::access_value(access_approach_t approach,
} }
else else
{ {
++stats_.misses; ++m_stats.misses;
} }
return result; return result;
@ -270,18 +270,18 @@ cache_result_t LRUStorage::access_value(access_approach_t approach,
*/ */
LRUStorage::Node* LRUStorage::vacate_lru() LRUStorage::Node* LRUStorage::vacate_lru()
{ {
ss_dassert(ptail_); ss_dassert(m_pTail);
Node* pnode = NULL; Node* pNode = NULL;
if (free_node_data(ptail_)) if (free_node_data(m_pTail))
{ {
pnode = ptail_; pNode = m_pTail;
remove_node(pnode); remove_node(pNode);
} }
return pnode; return pNode;
} }
/** /**
@ -293,27 +293,27 @@ LRUStorage::Node* LRUStorage::vacate_lru()
*/ */
LRUStorage::Node* LRUStorage::vacate_lru(size_t needed_space) LRUStorage::Node* LRUStorage::vacate_lru(size_t needed_space)
{ {
Node* pnode = NULL; Node* pNode = NULL;
size_t freed_space = 0; size_t freed_space = 0;
bool error = false; bool error = false;
while (!error && ptail_ && (freed_space < needed_space)) while (!error && m_pTail && (freed_space < needed_space))
{ {
size_t size = ptail_->size(); size_t size = m_pTail->size();
if (free_node_data(ptail_)) if (free_node_data(m_pTail))
{ {
freed_space += size; freed_space += size;
pnode = ptail_; pNode = m_pTail;
remove_node(pnode); remove_node(pNode);
if (freed_space < needed_space) if (freed_space < needed_space)
{ {
delete pnode; delete pNode;
pnode = NULL; pNode = NULL;
} }
} }
else else
@ -322,12 +322,12 @@ LRUStorage::Node* LRUStorage::vacate_lru(size_t needed_space)
} }
} }
if (pnode) if (pNode)
{ {
pnode->reset(); pNode->reset();
} }
return pnode; return pNode;
} }
/** /**
@ -335,22 +335,22 @@ LRUStorage::Node* LRUStorage::vacate_lru(size_t needed_space)
* *
* @return True, if the data could be freed, false otherwise. * @return True, if the data could be freed, false otherwise.
*/ */
bool LRUStorage::free_node_data(Node* pnode) bool LRUStorage::free_node_data(Node* pNode)
{ {
bool success = true; bool success = true;
const CACHE_KEY* pkey = pnode->key(); const CACHE_KEY* pkey = pNode->key();
ss_dassert(pkey); ss_dassert(pkey);
NodesByKey::iterator i = nodes_by_key_.find(*pkey); NodesByKey::iterator i = m_nodes_by_key.find(*pkey);
if (i == nodes_by_key_.end()) if (i == m_nodes_by_key.end())
{ {
ss_dassert(!true); ss_dassert(!true);
MXS_ERROR("Item in LRU list was not found in key mapping."); MXS_ERROR("Item in LRU list was not found in key mapping.");
} }
cache_result_t result = pstorage_->del_value(*pkey); cache_result_t result = m_pStorage->del_value(*pkey);
if (CACHE_RESULT_IS_OK(result) || CACHE_RESULT_IS_NOT_FOUND(result)) if (CACHE_RESULT_IS_OK(result) || CACHE_RESULT_IS_NOT_FOUND(result))
{ {
@ -360,17 +360,17 @@ bool LRUStorage::free_node_data(Node* pnode)
MXS_ERROR("Item in LRU list was not found in storage."); MXS_ERROR("Item in LRU list was not found in storage.");
} }
if (i != nodes_by_key_.end()) if (i != m_nodes_by_key.end())
{ {
nodes_by_key_.erase(i); m_nodes_by_key.erase(i);
} }
ss_dassert(stats_.size >= pnode->size()); ss_dassert(m_stats.size >= pNode->size());
ss_dassert(stats_.items > 0); ss_dassert(m_stats.items > 0);
stats_.size -= pnode->size(); m_stats.size -= pNode->size();
stats_.items -= 1; m_stats.items -= 1;
stats_.evictions += 1; m_stats.evictions += 1;
} }
else else
{ {
@ -386,15 +386,15 @@ bool LRUStorage::free_node_data(Node* pnode)
/** /**
* Free a node and update head/tail accordingly. * Free a node and update head/tail accordingly.
* *
* @param pnode The node to be freed. * @param pNode The node to be freed.
*/ */
void LRUStorage::free_node(Node* pnode) const void LRUStorage::free_node(Node* pNode) const
{ {
remove_node(pnode); remove_node(pNode);
delete pnode; delete pNode;
ss_dassert(!phead_ || (phead_->prev() == NULL)); ss_dassert(!m_pHead || (m_pHead->prev() == NULL));
ss_dassert(!ptail_ || (ptail_->next() == NULL)); ss_dassert(!m_pTail || (m_pTail->next() == NULL));
} }
/** /**
@ -405,71 +405,71 @@ void LRUStorage::free_node(Node* pnode) const
void LRUStorage::free_node(NodesByKey::iterator& i) const void LRUStorage::free_node(NodesByKey::iterator& i) const
{ {
free_node(i->second); // A Node free_node(i->second); // A Node
nodes_by_key_.erase(i); m_nodes_by_key.erase(i);
} }
/** /**
* Remove a node and update head/tail accordingly. * Remove a node and update head/tail accordingly.
* *
* @param pnode The node to be removed. * @param pNode The node to be removed.
*/ */
void LRUStorage::remove_node(Node* pnode) const void LRUStorage::remove_node(Node* pNode) const
{ {
ss_dassert(phead_->prev() == NULL); ss_dassert(m_pHead->prev() == NULL);
ss_dassert(ptail_->next() == NULL); ss_dassert(m_pTail->next() == NULL);
if (phead_ == pnode) if (m_pHead == pNode)
{ {
phead_ = phead_->next(); m_pHead = m_pHead->next();
} }
if (ptail_ == pnode) if (m_pTail == pNode)
{ {
ptail_ = ptail_->prev(); m_pTail = m_pTail->prev();
} }
pnode->remove(); pNode->remove();
ss_dassert(!phead_ || (phead_->prev() == NULL)); ss_dassert(!m_pHead || (m_pHead->prev() == NULL));
ss_dassert(!ptail_ || (ptail_->next() == NULL)); ss_dassert(!m_pTail || (m_pTail->next() == NULL));
} }
/** /**
* Move a node to head. * Move a node to head.
* *
* @param pnode The node to be moved to head. * @param pNode The node to be moved to head.
*/ */
void LRUStorage::move_to_head(Node* pnode) const void LRUStorage::move_to_head(Node* pNode) const
{ {
ss_dassert(!phead_ || (phead_->prev() == NULL)); ss_dassert(!m_pHead || (m_pHead->prev() == NULL));
ss_dassert(!ptail_ || (ptail_->next() == NULL)); ss_dassert(!m_pTail || (m_pTail->next() == NULL));
if (ptail_ == pnode) if (m_pTail == pNode)
{ {
ptail_ = pnode->prev(); m_pTail = pNode->prev();
} }
phead_ = pnode->prepend(phead_); m_pHead = pNode->prepend(m_pHead);
if (!ptail_) if (!m_pTail)
{ {
ptail_ = phead_; m_pTail = m_pHead;
} }
ss_dassert(phead_); ss_dassert(m_pHead);
ss_dassert(ptail_); ss_dassert(m_pTail);
ss_dassert((phead_ != ptail_) || (phead_ == pnode)); ss_dassert((m_pHead != m_pTail) || (m_pHead == pNode));
ss_dassert(phead_->prev() == NULL); ss_dassert(m_pHead->prev() == NULL);
ss_dassert(ptail_->next() == NULL); ss_dassert(m_pTail->next() == NULL);
} }
cache_result_t LRUStorage::get_existing_node(NodesByKey::iterator& i, const GWBUF* pvalue, Node** ppnode) cache_result_t LRUStorage::get_existing_node(NodesByKey::iterator& i, const GWBUF* pValue, Node** ppNode)
{ {
cache_result_t result = CACHE_RESULT_OK; cache_result_t result = CACHE_RESULT_OK;
size_t value_size = GWBUF_LENGTH(pvalue); size_t value_size = GWBUF_LENGTH(pValue);
if (value_size > max_size_) if (value_size > m_max_size)
{ {
// If the size of the new item is more than what is allowed in total, // If the size of the new item is more than what is allowed in total,
// we must remove the value. // we must remove the value.
@ -486,28 +486,28 @@ cache_result_t LRUStorage::get_existing_node(NodesByKey::iterator& i, const GWBU
} }
else else
{ {
Node* pnode = i->second; Node* pNode = i->second;
size_t new_size = stats_.size - pnode->size() + value_size; size_t new_size = m_stats.size - pNode->size() + value_size;
if (new_size > max_size_) if (new_size > m_max_size)
{ {
ss_dassert(value_size > pnode->size()); ss_dassert(value_size > pNode->size());
// We move it to the front, so that we do not have to deal with the case // We move it to the front, so that we do not have to deal with the case
// that 'pnode' is subject to removal. // that 'pNode' is subject to removal.
move_to_head(pnode); move_to_head(pNode);
size_t extra_size = value_size - pnode->size(); size_t extra_size = value_size - pNode->size();
Node* pvacant_node = vacate_lru(extra_size); Node* pVacant_node = vacate_lru(extra_size);
if (pvacant_node) if (pVacant_node)
{ {
// We won't be using the node. // We won't be using the node.
free_node(pvacant_node); free_node(pVacant_node);
*ppnode = pnode; *ppNode = pNode;
} }
else else
{ {
@ -518,8 +518,8 @@ cache_result_t LRUStorage::get_existing_node(NodesByKey::iterator& i, const GWBU
} }
else else
{ {
ss_dassert(stats_.items <= max_count_); ss_dassert(m_stats.items <= m_max_count);
*ppnode = pnode; *ppNode = pNode;
} }
} }
@ -527,83 +527,83 @@ cache_result_t LRUStorage::get_existing_node(NodesByKey::iterator& i, const GWBU
} }
cache_result_t LRUStorage::get_new_node(const CACHE_KEY& key, cache_result_t LRUStorage::get_new_node(const CACHE_KEY& key,
const GWBUF* pvalue, const GWBUF* pValue,
NodesByKey::iterator* pI, NodesByKey::iterator* pI,
Node** ppnode) Node** ppNode)
{ {
cache_result_t result = CACHE_RESULT_OK; cache_result_t result = CACHE_RESULT_OK;
size_t value_size = GWBUF_LENGTH(pvalue); size_t value_size = GWBUF_LENGTH(pValue);
size_t new_size = stats_.size + value_size; size_t new_size = m_stats.size + value_size;
Node* pnode = NULL; Node* pNode = NULL;
if ((new_size > max_size_) || (stats_.items == max_count_)) if ((new_size > m_max_size) || (m_stats.items == m_max_count))
{ {
if (new_size > max_size_) if (new_size > m_max_size)
{ {
pnode = vacate_lru(value_size); pNode = vacate_lru(value_size);
} }
else if (stats_.items == max_count_) else if (m_stats.items == m_max_count)
{ {
ss_dassert(stats_.items == max_count_); ss_dassert(m_stats.items == m_max_count);
pnode = vacate_lru(); pNode = vacate_lru();
} }
if (!pnode) if (!pNode)
{ {
result = CACHE_RESULT_ERROR; result = CACHE_RESULT_ERROR;
} }
} }
else else
{ {
pnode = new (std::nothrow) Node; pNode = new (std::nothrow) Node;
} }
if (pnode) if (pNode)
{ {
try try
{ {
std::pair<NodesByKey::iterator, bool> rv; std::pair<NodesByKey::iterator, bool> rv;
rv = nodes_by_key_.insert(std::make_pair(key, pnode)); rv = m_nodes_by_key.insert(std::make_pair(key, pNode));
ss_dassert(rv.second); // If true, the item was inserted as new (and not updated). ss_dassert(rv.second); // If true, the item was inserted as new (and not updated).
*pI = rv.first; *pI = rv.first;
} }
catch (const std::exception& x) catch (const std::exception& x)
{ {
delete pnode; delete pNode;
pnode = NULL; pNode = NULL;
result = CACHE_RESULT_OUT_OF_RESOURCES; result = CACHE_RESULT_OUT_OF_RESOURCES;
} }
} }
if (CACHE_RESULT_IS_OK(result)) if (CACHE_RESULT_IS_OK(result))
{ {
ss_dassert(pnode); ss_dassert(pNode);
*ppnode = pnode; *ppNode = pNode;
} }
return result; return result;
} }
static void set_integer(json_t* pobject, const char* zname, size_t value) static void set_integer(json_t* pObject, const char* zName, size_t value)
{ {
json_t* pvalue = json_integer(value); json_t* pValue = json_integer(value);
if (pvalue) if (pValue)
{ {
json_object_set(pobject, zname, pvalue); json_object_set(pObject, zName, pValue);
json_decref(pvalue); json_decref(pValue);
} }
} }
void LRUStorage::Stats::fill(json_t* pbject) const void LRUStorage::Stats::fill(json_t* pObject) const
{ {
set_integer(pbject, "size", size); set_integer(pObject, "size", size);
set_integer(pbject, "items", items); set_integer(pObject, "items", items);
set_integer(pbject, "hits", hits); set_integer(pObject, "hits", hits);
set_integer(pbject, "misses", misses); set_integer(pObject, "misses", misses);
set_integer(pbject, "updates", updates); set_integer(pObject, "updates", updates);
set_integer(pbject, "deletes", deletes); set_integer(pObject, "deletes", deletes);
set_integer(pbject, "evictions", evictions); set_integer(pObject, "evictions", evictions);
} }

View File

@ -31,12 +31,12 @@ public:
/** /**
* @see Storage::get_key * @see Storage::get_key
*/ */
cache_result_t get_key(const char* zDefaultDb, cache_result_t get_key(const char* zDefault_db,
const GWBUF* pQuery, const GWBUF* pQuery,
CACHE_KEY* pKey) const; CACHE_KEY* pKey) const;
protected: protected:
LRUStorage(const CACHE_STORAGE_CONFIG& config, Storage* pstorage); LRUStorage(const CACHE_STORAGE_CONFIG& config, Storage* pStorage);
/** /**
* @see Storage::get_info * @see Storage::get_info
@ -112,10 +112,10 @@ private:
{ {
public: public:
Node() Node()
: pkey_(NULL) : m_pKey(NULL)
, size_(0) , m_size(0)
, pnext_(NULL) , m_pNext(NULL)
, pprev_(NULL) , m_pPrev(NULL)
{} {}
~Node() ~Node()
{ {
@ -124,19 +124,19 @@ private:
const CACHE_KEY* key() const const CACHE_KEY* key() const
{ {
return pkey_; return m_pKey;
} }
size_t size() const size_t size() const
{ {
return size_; return m_size;
} }
Node* next() const Node* next() const
{ {
return pnext_; return m_pNext;
} }
Node* prev() const Node* prev() const
{ {
return pprev_; return m_pPrev;
} }
/** /**
@ -145,29 +145,29 @@ private:
* @param pnode The node in front of which this should be moved. * @param pnode The node in front of which this should be moved.
* @return This node. * @return This node.
*/ */
Node* prepend(Node* pnode) Node* prepend(Node* pNode)
{ {
if (pnode && (pnode != this)) if (pNode && (pNode != this))
{ {
if (pprev_) if (m_pPrev)
{ {
pprev_->pnext_ = pnext_; m_pPrev->m_pNext = m_pNext;
} }
if (pnext_) if (m_pNext)
{ {
pnext_->pprev_ = pprev_; m_pNext->m_pPrev = m_pPrev;
} }
if (pnode->pprev_) if (pNode->m_pPrev)
{ {
pnode->pprev_->pnext_ = this; pNode->m_pPrev->m_pNext = this;
} }
pprev_ = pnode->pprev_; m_pPrev = pNode->m_pPrev;
pnext_ = pnode; m_pNext = pNode;
pnode->pprev_ = this; pNode->m_pPrev = this;
} }
return this; return this;
@ -180,52 +180,52 @@ private:
*/ */
Node* remove() Node* remove()
{ {
if (pprev_) if (m_pPrev)
{ {
pprev_->pnext_ = pnext_; m_pPrev->m_pNext = m_pNext;
} }
if (pnext_) if (m_pNext)
{ {
pnext_->pprev_ = pprev_; m_pNext->m_pPrev = m_pPrev;
} }
Node* pnode = (pprev_ ? pprev_ : pnext_); Node* pNode = (m_pPrev ? m_pPrev : m_pNext);
pprev_ = NULL; m_pPrev = NULL;
pnext_ = NULL; m_pNext = NULL;
return pnode; return pNode;
} }
void reset(const CACHE_KEY* pkey = NULL, size_t size = 0) void reset(const CACHE_KEY* pkey = NULL, size_t size = 0)
{ {
pkey_ = pkey; m_pKey = pkey;
size_ = size; m_size = size;
} }
private: private:
const CACHE_KEY* pkey_; /*< Points at the key stored in nodes_by_key_ below. */ const CACHE_KEY* m_pKey; /*< Points at the key stored in nodes_by_key_ below. */
size_t size_; /*< The size of the data referred to by pkey_. */ size_t m_size; /*< The size of the data referred to by m_pKey. */
Node* pnext_; /*< The next node in the LRU list. */ Node* m_pNext; /*< The next node in the LRU list. */
Node* pprev_; /*< The previous node in the LRU list. */ Node* m_pPrev; /*< The previous node in the LRU list. */
}; };
typedef std::tr1::unordered_map<CACHE_KEY, Node*> NodesByKey; typedef std::tr1::unordered_map<CACHE_KEY, Node*> NodesByKey;
Node* vacate_lru(); Node* vacate_lru();
Node* vacate_lru(size_t space); Node* vacate_lru(size_t space);
bool free_node_data(Node* pnode); bool free_node_data(Node* pNode);
void free_node(Node* pnode) const; void free_node(Node* pNode) const;
void free_node(NodesByKey::iterator& i) const; void free_node(NodesByKey::iterator& i) const;
void remove_node(Node* pnode) const; void remove_node(Node* pNode) const;
void move_to_head(Node* pnode) const; void move_to_head(Node* pNode) const;
cache_result_t get_existing_node(NodesByKey::iterator& i, const GWBUF* pvalue, Node** ppnode); cache_result_t get_existing_node(NodesByKey::iterator& i, const GWBUF* pvalue, Node** ppNode);
cache_result_t get_new_node(const CACHE_KEY& key, cache_result_t get_new_node(const CACHE_KEY& key,
const GWBUF* pvalue, const GWBUF* pValue,
NodesByKey::iterator* pI, NodesByKey::iterator* pI,
Node** ppnode); Node** ppNode);
private: private:
struct Stats struct Stats
@ -240,7 +240,7 @@ private:
, evictions(0) , evictions(0)
{} {}
void fill(json_t* pbject) const; void fill(json_t* pObject) const;
uint64_t size; /*< The total size of the stored values. */ uint64_t size; /*< The total size of the stored values. */
uint64_t items; /*< The number of stored items. */ uint64_t items; /*< The number of stored items. */
@ -251,12 +251,12 @@ private:
uint64_t evictions; /*< How many times an item has been evicted from the cache. */ uint64_t evictions; /*< How many times an item has been evicted from the cache. */
}; };
const CACHE_STORAGE_CONFIG config_; /*< The configuration. */ const CACHE_STORAGE_CONFIG m_config; /*< The configuration. */
Storage* pstorage_; /*< The actual storage. */ Storage* m_pStorage; /*< The actual storage. */
const uint64_t max_count_; /*< The maximum number of items in the LRU list, */ const uint64_t m_max_count; /*< The maximum number of items in the LRU list, */
const uint64_t max_size_; /*< The maximum size of all cached items. */ const uint64_t m_max_size; /*< The maximum size of all cached items. */
mutable Stats stats_; /*< Cache statistics. */ mutable Stats m_stats; /*< Cache statistics. */
mutable NodesByKey nodes_by_key_; /*< Mapping from cache keys to corresponding Node. */ mutable NodesByKey m_nodes_by_key; /*< Mapping from cache keys to corresponding Node. */
mutable Node* phead_; /*< The node at the LRU list. */ mutable Node* m_pHead; /*< The node at the LRU list. */
mutable Node* ptail_; /*< The node at bottom of the LRU list.*/ mutable Node* m_pTail; /*< The node at bottom of the LRU list.*/
}; };

View File

@ -16,10 +16,10 @@
using maxscale::SpinLockGuard; using maxscale::SpinLockGuard;
LRUStorageMT::LRUStorageMT(const CACHE_STORAGE_CONFIG& config, Storage* pstorage) LRUStorageMT::LRUStorageMT(const CACHE_STORAGE_CONFIG& config, Storage* pStorage)
: LRUStorage(config, pstorage) : LRUStorage(config, pStorage)
{ {
spinlock_init(&lock_); spinlock_init(&m_lock);
MXS_NOTICE("Created multi threaded LRU storage."); MXS_NOTICE("Created multi threaded LRU storage.");
} }
@ -28,11 +28,11 @@ LRUStorageMT::~LRUStorageMT()
{ {
} }
LRUStorageMT* LRUStorageMT::create(const CACHE_STORAGE_CONFIG& config, Storage* pstorage) LRUStorageMT* LRUStorageMT::create(const CACHE_STORAGE_CONFIG& config, Storage* pStorage)
{ {
LRUStorageMT* plru_storage = NULL; LRUStorageMT* plru_storage = NULL;
MXS_EXCEPTION_GUARD(plru_storage = new LRUStorageMT(config, pstorage)); MXS_EXCEPTION_GUARD(plru_storage = new LRUStorageMT(config, pStorage));
return plru_storage; return plru_storage;
} }
@ -40,58 +40,58 @@ LRUStorageMT* LRUStorageMT::create(const CACHE_STORAGE_CONFIG& config, Storage*
cache_result_t LRUStorageMT::get_info(uint32_t what, cache_result_t LRUStorageMT::get_info(uint32_t what,
json_t** ppInfo) const json_t** ppInfo) const
{ {
SpinLockGuard guard(lock_); SpinLockGuard guard(m_lock);
return LRUStorage::do_get_info(what, ppInfo); return LRUStorage::do_get_info(what, ppInfo);
} }
cache_result_t LRUStorageMT::get_value(const CACHE_KEY& key, cache_result_t LRUStorageMT::get_value(const CACHE_KEY& key,
uint32_t flags, uint32_t flags,
GWBUF** ppvalue) const GWBUF** ppValue) const
{ {
SpinLockGuard guard(lock_); SpinLockGuard guard(m_lock);
return do_get_value(key, flags, ppvalue); return do_get_value(key, flags, ppValue);
} }
cache_result_t LRUStorageMT::put_value(const CACHE_KEY& key, const GWBUF* pvalue) cache_result_t LRUStorageMT::put_value(const CACHE_KEY& key, const GWBUF* pValue)
{ {
SpinLockGuard guard(lock_); SpinLockGuard guard(m_lock);
return do_put_value(key, pvalue); return do_put_value(key, pValue);
} }
cache_result_t LRUStorageMT::del_value(const CACHE_KEY& key) cache_result_t LRUStorageMT::del_value(const CACHE_KEY& key)
{ {
SpinLockGuard guard(lock_); SpinLockGuard guard(m_lock);
return do_del_value(key); return do_del_value(key);
} }
cache_result_t LRUStorageMT::get_head(CACHE_KEY* pKey, GWBUF** ppHead) const cache_result_t LRUStorageMT::get_head(CACHE_KEY* pKey, GWBUF** ppHead) const
{ {
SpinLockGuard guard(lock_); SpinLockGuard guard(m_lock);
return LRUStorage::do_get_head(pKey, ppHead); return LRUStorage::do_get_head(pKey, ppHead);
} }
cache_result_t LRUStorageMT::get_tail(CACHE_KEY* pKey, GWBUF** ppTail) const cache_result_t LRUStorageMT::get_tail(CACHE_KEY* pKey, GWBUF** ppTail) const
{ {
SpinLockGuard guard(lock_); SpinLockGuard guard(m_lock);
return LRUStorage::do_get_tail(pKey, ppTail); return LRUStorage::do_get_tail(pKey, ppTail);
} }
cache_result_t LRUStorageMT::get_size(uint64_t* pSize) const cache_result_t LRUStorageMT::get_size(uint64_t* pSize) const
{ {
SpinLockGuard guard(lock_); SpinLockGuard guard(m_lock);
return LRUStorage::do_get_size(pSize); return LRUStorage::do_get_size(pSize);
} }
cache_result_t LRUStorageMT::get_items(uint64_t* pItems) const cache_result_t LRUStorageMT::get_items(uint64_t* pItems) const
{ {
SpinLockGuard guard(lock_); SpinLockGuard guard(m_lock);
return LRUStorage::do_get_items(pItems); return LRUStorage::do_get_items(pItems);
} }

View File

@ -28,10 +28,10 @@ public:
cache_result_t get_value(const CACHE_KEY& key, cache_result_t get_value(const CACHE_KEY& key,
uint32_t flags, uint32_t flags,
GWBUF** ppvalue) const; GWBUF** ppValue) const;
cache_result_t put_value(const CACHE_KEY& key, cache_result_t put_value(const CACHE_KEY& key,
const GWBUF* pvalue); const GWBUF* pValue);
cache_result_t del_value(const CACHE_KEY& key); cache_result_t del_value(const CACHE_KEY& key);
@ -46,11 +46,11 @@ public:
cache_result_t get_items(uint64_t* pItems) const; cache_result_t get_items(uint64_t* pItems) const;
private: private:
LRUStorageMT(const CACHE_STORAGE_CONFIG& config, Storage* pstorage); LRUStorageMT(const CACHE_STORAGE_CONFIG& config, Storage* pStorage);
LRUStorageMT(const LRUStorageMT&); LRUStorageMT(const LRUStorageMT&);
LRUStorageMT& operator = (const LRUStorageMT&); LRUStorageMT& operator = (const LRUStorageMT&);
private: private:
mutable SPINLOCK lock_; mutable SPINLOCK m_lock;
}; };

View File

@ -14,8 +14,8 @@
#define MXS_MODULE_NAME "cache" #define MXS_MODULE_NAME "cache"
#include "lrustoragest.hh" #include "lrustoragest.hh"
LRUStorageST::LRUStorageST(const CACHE_STORAGE_CONFIG& config, Storage* pstorage) LRUStorageST::LRUStorageST(const CACHE_STORAGE_CONFIG& config, Storage* pStorage)
: LRUStorage(config, pstorage) : LRUStorage(config, pStorage)
{ {
MXS_NOTICE("Created single threaded LRU storage."); MXS_NOTICE("Created single threaded LRU storage.");
} }
@ -24,11 +24,11 @@ LRUStorageST::~LRUStorageST()
{ {
} }
LRUStorageST* LRUStorageST::create(const CACHE_STORAGE_CONFIG& config, Storage* pstorage) LRUStorageST* LRUStorageST::create(const CACHE_STORAGE_CONFIG& config, Storage* pStorage)
{ {
LRUStorageST* plru_storage = NULL; LRUStorageST* plru_storage = NULL;
MXS_EXCEPTION_GUARD(plru_storage = new LRUStorageST(config, pstorage)); MXS_EXCEPTION_GUARD(plru_storage = new LRUStorageST(config, pStorage));
return plru_storage; return plru_storage;
} }
@ -41,14 +41,14 @@ cache_result_t LRUStorageST::get_info(uint32_t what,
cache_result_t LRUStorageST::get_value(const CACHE_KEY& key, cache_result_t LRUStorageST::get_value(const CACHE_KEY& key,
uint32_t flags, uint32_t flags,
GWBUF** ppvalue) const GWBUF** ppValue) const
{ {
return LRUStorage::do_get_value(key, flags, ppvalue); return LRUStorage::do_get_value(key, flags, ppValue);
} }
cache_result_t LRUStorageST::put_value(const CACHE_KEY& key, const GWBUF* pvalue) cache_result_t LRUStorageST::put_value(const CACHE_KEY& key, const GWBUF* pValue)
{ {
return LRUStorage::do_put_value(key, pvalue); return LRUStorage::do_put_value(key, pValue);
} }
cache_result_t LRUStorageST::del_value(const CACHE_KEY& key) cache_result_t LRUStorageST::del_value(const CACHE_KEY& key)

View File

@ -359,59 +359,59 @@ bool cache_rules_should_use(CACHE_RULES *self, const MXS_SESSION *session)
} }
CacheRules::CacheRules(CACHE_RULES* prules) CacheRules::CacheRules(CACHE_RULES* pRules)
: prules_(prules) : m_pRules(pRules)
{ {
} }
CacheRules::~CacheRules() CacheRules::~CacheRules()
{ {
cache_rules_free(prules_); cache_rules_free(m_pRules);
} }
// static // static
CacheRules* CacheRules::create(uint32_t debug) CacheRules* CacheRules::create(uint32_t debug)
{ {
CacheRules* pthis = NULL; CacheRules* pThis = NULL;
CACHE_RULES* prules = cache_rules_create(debug); CACHE_RULES* pRules = cache_rules_create(debug);
if (prules) if (pRules)
{ {
pthis = new (std::nothrow) CacheRules(prules); pThis = new (std::nothrow) CacheRules(pRules);
} }
return pthis; return pThis;
} }
// static // static
CacheRules* CacheRules::load(const char *zpath, uint32_t debug) CacheRules* CacheRules::load(const char *zPath, uint32_t debug)
{ {
CacheRules* pthis = NULL; CacheRules* pThis = NULL;
CACHE_RULES* prules = cache_rules_load(zpath, debug); CACHE_RULES* pRules = cache_rules_load(zPath, debug);
if (prules) if (pRules)
{ {
pthis = new (std::nothrow) CacheRules(prules); pThis = new (std::nothrow) CacheRules(pRules);
} }
return pthis; return pThis;
} }
const json_t* CacheRules::json() const const json_t* CacheRules::json() const
{ {
return prules_->root; return m_pRules->root;
} }
bool CacheRules::should_store(const char* zdefault_db, const GWBUF* pquery) const bool CacheRules::should_store(const char* zDefault_db, const GWBUF* pQuery) const
{ {
return cache_rules_should_store(prules_, zdefault_db, pquery); return cache_rules_should_store(m_pRules, zDefault_db, pQuery);
} }
bool CacheRules::should_use(const MXS_SESSION* psession) const bool CacheRules::should_use(const MXS_SESSION* pSession) const
{ {
return cache_rules_should_use(prules_, psession); return cache_rules_should_use(m_pRules, pSession);
} }
/* /*

View File

@ -180,7 +180,7 @@ public:
* *
* @return The corresponding rules object, or NULL in case of error. * @return The corresponding rules object, or NULL in case of error.
*/ */
static CacheRules* load(const char *zpath, uint32_t debug); static CacheRules* load(const char *zPath, uint32_t debug);
/** /**
* Returns the json rules object. * Returns the json rules object.
@ -200,7 +200,7 @@ public:
* *
* @return True, if the results should be stored. * @return True, if the results should be stored.
*/ */
bool should_store(const char* zdefault_db, const GWBUF* pquery) const; bool should_store(const char* zDefault_db, const GWBUF* pQuery) const;
/** /**
* Returns boolean indicating whether the cache should be used, that is consulted. * Returns boolean indicating whether the cache should be used, that is consulted.
@ -209,16 +209,16 @@ public:
* *
* @return True, if the cache should be used. * @return True, if the cache should be used.
*/ */
bool should_use(const MXS_SESSION* psession) const; bool should_use(const MXS_SESSION* pSession) const;
private: private:
CacheRules(CACHE_RULES* prules); CacheRules(CACHE_RULES* pRules);
CacheRules(const CacheRules&); CacheRules(const CacheRules&);
CacheRules& operator = (const CacheRules&); CacheRules& operator = (const CacheRules&);
private: private:
CACHE_RULES* prules_; CACHE_RULES* m_pRules;
}; };
#endif #endif

View File

@ -80,7 +80,7 @@ private:
, deletes(0) , deletes(0)
{} {}
void fill(json_t* pbject) const; void fill(json_t* pObject) const;
uint64_t size; /*< The total size of the stored values. */ uint64_t size; /*< The total size of the stored values. */
uint64_t items; /*< The number of stored items. */ uint64_t items; /*< The number of stored items. */

View File

@ -21,7 +21,7 @@ InMemoryStorageMT::InMemoryStorageMT(const std::string& name,
const CACHE_STORAGE_CONFIG& config) const CACHE_STORAGE_CONFIG& config)
: InMemoryStorage(name, config) : InMemoryStorage(name, config)
{ {
spinlock_init(&lock_); spinlock_init(&m_lock);
} }
InMemoryStorageMT::~InMemoryStorageMT() InMemoryStorageMT::~InMemoryStorageMT()
@ -37,28 +37,28 @@ auto_ptr<InMemoryStorageMT> InMemoryStorageMT::Create(const std::string& name,
cache_result_t InMemoryStorageMT::get_info(uint32_t what, json_t** ppInfo) const cache_result_t InMemoryStorageMT::get_info(uint32_t what, json_t** ppInfo) const
{ {
SpinLockGuard guard(lock_); SpinLockGuard guard(m_lock);
return do_get_info(what, ppInfo); return do_get_info(what, ppInfo);
} }
cache_result_t InMemoryStorageMT::get_value(const CACHE_KEY& key, uint32_t flags, GWBUF** ppResult) cache_result_t InMemoryStorageMT::get_value(const CACHE_KEY& key, uint32_t flags, GWBUF** ppResult)
{ {
SpinLockGuard guard(lock_); SpinLockGuard guard(m_lock);
return do_get_value(key, flags, ppResult); return do_get_value(key, flags, ppResult);
} }
cache_result_t InMemoryStorageMT::put_value(const CACHE_KEY& key, const GWBUF& value) cache_result_t InMemoryStorageMT::put_value(const CACHE_KEY& key, const GWBUF& value)
{ {
SpinLockGuard guard(lock_); SpinLockGuard guard(m_lock);
return do_put_value(key, value); return do_put_value(key, value);
} }
cache_result_t InMemoryStorageMT::del_value(const CACHE_KEY& key) cache_result_t InMemoryStorageMT::del_value(const CACHE_KEY& key)
{ {
SpinLockGuard guard(lock_); SpinLockGuard guard(m_lock);
return do_del_value(key); return do_del_value(key);
} }

View File

@ -40,5 +40,5 @@ private:
InMemoryStorageMT& operator = (const InMemoryStorageMT&); InMemoryStorageMT& operator = (const InMemoryStorageMT&);
private: private:
mutable SPINLOCK lock_; mutable SPINLOCK m_lock;
}; };