From d8cc833da6167ecadbbe94beb64a5453d2927367 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 30 Oct 2017 20:25:16 +0000 Subject: Use std::shared_ptr and variadic calls to make_shared in fuse components --- netfs/fuse/fuseApp.h | 12 ++++++------ netfs/fuse/fuseApp.impl.h | 6 +++--- netfs/fuse/fuseDirs.cpp | 2 +- netfs/fuse/fuseFiles.cpp | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/netfs/fuse/fuseApp.h b/netfs/fuse/fuseApp.h index 1e43166..3f4d40d 100644 --- a/netfs/fuse/fuseApp.h +++ b/netfs/fuse/fuseApp.h @@ -17,7 +17,7 @@ namespace NetFS { class DLL_PUBLIC FuseApp : public FuseAppBase { private: - class OpenDir : public IceUtil::Shared { + class OpenDir { public: OpenDir(DirectoryPrx remote, const std::string & path); @@ -25,10 +25,10 @@ namespace NetFS { DirectoryV2Prx remoteV2; const std::string path; }; - typedef IceUtil::Handle OpenDirPtr; + typedef std::shared_ptr OpenDirPtr; typedef std::map OpenDirs; - class OpenFile : public IceUtil::Shared { + class OpenFile { public: OpenFile(FilePrx remote, const std::string & path, int flags); @@ -42,7 +42,7 @@ namespace NetFS { std::list bg; mutable boost::shared_mutex _lock; }; - typedef IceUtil::Handle OpenFilePtr; + typedef std::shared_ptr OpenFilePtr; typedef std::map OpenFiles; public: @@ -104,8 +104,8 @@ namespace NetFS { virtual NetFS::Client::ResourcePtr configureFromUri(const std::string &) const; private: - template - void setProxy(const Handle &, uint64_t & fh); + template + void setProxy(uint64_t & fh, const Params & ...); template Handle getProxy(uint64_t localID); template diff --git a/netfs/fuse/fuseApp.impl.h b/netfs/fuse/fuseApp.impl.h index 66fe3b2..9d73de0 100644 --- a/netfs/fuse/fuseApp.impl.h +++ b/netfs/fuse/fuseApp.impl.h @@ -6,14 +6,14 @@ #include namespace NetFS { - template + template void - FuseApp::setProxy(const Handle & od, uint64_t & fh) + FuseApp::setProxy(uint64_t & fh, const Params & ... params) { auto & map = getMap(); Lock(_lock); while (map.find(fh = ++openHandleId) != map.end()) ; - map.emplace(fh, od); + map.emplace(fh, std::make_shared(params...)); } template diff --git a/netfs/fuse/fuseDirs.cpp b/netfs/fuse/fuseDirs.cpp index 3325375..c277798 100644 --- a/netfs/fuse/fuseDirs.cpp +++ b/netfs/fuse/fuseDirs.cpp @@ -22,7 +22,7 @@ FuseApp::opendir(const char * p, struct fuse_file_info * fi) { try { auto remote = volume->opendir(reqEnv(), p); - setProxy(new OpenDir(remote, p), fi->fh); + setProxy(fi->fh, remote, p); return 0; } catch (SystemError & e) { diff --git a/netfs/fuse/fuseFiles.cpp b/netfs/fuse/fuseFiles.cpp index 350e74f..4c93d56 100644 --- a/netfs/fuse/fuseFiles.cpp +++ b/netfs/fuse/fuseFiles.cpp @@ -62,7 +62,7 @@ FuseApp::open(const char * p, struct fuse_file_info * fi) { try { auto remote = volume->open(reqEnv(), p, fi->flags); - setProxy(new OpenFile(remote, p, fi->flags), fi->fh); + setProxy(fi->fh, remote, p, fi->flags); return 0; } catch (SystemError & e) { @@ -75,7 +75,7 @@ FuseApp::create(const char * p, mode_t m, struct fuse_file_info * fi) { try { auto remote = volume->create(reqEnv(), p, fi->flags, m); - setProxy(new OpenFile(remote, p, fi->flags), fi->fh); + setProxy(fi->fh, remote, p, fi->flags); return 0; } catch (SystemError & e) { -- cgit v1.2.3