Commit 82ebc287 authored by Elvin Sindrilaru's avatar Elvin Sindrilaru

FUSE: Implement move constructor and delete copy constructor for ProcCache

parent f8235653
......@@ -44,6 +44,32 @@ int gProcCacheShardSize;
ProcCache gProcCache;
//------------------------------------------------------------------------------
// Move constructor
//------------------------------------------------------------------------------
ProcCache::ProcCache(ProcCache&& other)
{
*this = std::move(other);
}
//------------------------------------------------------------------------------
// Move assignment operator
//------------------------------------------------------------------------------
ProcCache&
ProcCache::operator=(ProcCache&& other)
{
if (this != &other) {
std::swap(this->pMutex, other.pMutex);
std::swap(this->pCatalog, other.pCatalog);
this->pProcPath = other.pProcPath;
}
return *this;
}
//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
int ProcReaderCmdLine::ReadContent(std::vector<std::string>& cmdLine)
{
int ret = 1;
......
......@@ -311,11 +311,18 @@ class ProcCache
std::string pProcPath;
public:
//----------------------------------------------------------------------------
//! Constructor
//----------------------------------------------------------------------------
ProcCache()
{
pMutex.SetBlocking(true);
pProcPath = "/proc/";
}
//----------------------------------------------------------------------------
//! Destructor
//----------------------------------------------------------------------------
~ProcCache()
{
eos::common::RWMutexWriteLock lock(pMutex);
......@@ -325,6 +332,27 @@ public:
}
}
//----------------------------------------------------------------------------
//! Move constructor
//----------------------------------------------------------------------------
ProcCache(ProcCache&& other);
//----------------------------------------------------------------------------
//! Move assignment operator
//----------------------------------------------------------------------------
ProcCache& operator=(ProcCache&& other);
//----------------------------------------------------------------------------
//! Copy constructor
//----------------------------------------------------------------------------
ProcCache(const ProcCache&) = delete;
//----------------------------------------------------------------------------
//! Copy assignment operator
//----------------------------------------------------------------------------
ProcCache& operator=(const ProcCache&) = delete;
//! returns true if the cache has an entry for the given pid, false else
//! regardless of the fact it's up-to-date or not
bool HasEntry(int pid)
......@@ -397,7 +425,7 @@ public:
if (protect && protect->count(it->first)) {
++it;
} else {
delete it->second;
delete it->second;
pCatalog.erase(it++);
++count;
}
......
......@@ -48,6 +48,7 @@
#include "XrdCl/XrdClXRootDResponses.hh"
#include "MacOSXHelper.hh"
#include "FuseCache/CacheEntry.hh"
#include "ProcCache.hh"
#include "common/XrdErrorMap.hh"
#include "filesystem.hh"
#include "xrdutils.hh"
......
......@@ -49,7 +49,6 @@
#include <google/sparse_hash_map>
#include <google/sparsehash/densehashtable.h>
#include "FuseCacheEntry.hh"
#include "ProcCache.hh"
#include "fst/layout/LayoutPlugin.hh"
#include "fst/layout/PlainLayout.hh"
#include "fst/layout/RaidDpLayout.hh"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment