diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-10-30 20:25:16 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-12-16 20:51:55 +0000 |
commit | d8cc833da6167ecadbbe94beb64a5453d2927367 (patch) | |
tree | dd1f5942630efcf1f16e3582fab26ebb9c33b74d | |
parent | Single [template] implementation of proxy wrapper maps for open files and dir... (diff) | |
download | netfs-d8cc833da6167ecadbbe94beb64a5453d2927367.tar.bz2 netfs-d8cc833da6167ecadbbe94beb64a5453d2927367.tar.xz netfs-d8cc833da6167ecadbbe94beb64a5453d2927367.zip |
Use std::shared_ptr and variadic calls to make_shared in fuse components
-rw-r--r-- | netfs/fuse/fuseApp.h | 12 | ||||
-rw-r--r-- | netfs/fuse/fuseApp.impl.h | 6 | ||||
-rw-r--r-- | netfs/fuse/fuseDirs.cpp | 2 | ||||
-rw-r--r-- | 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<OpenDir> OpenDirPtr; + typedef std::shared_ptr<OpenDir> OpenDirPtr; typedef std::map<int, OpenDirPtr> 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<Ice::AsyncResultPtr> bg; mutable boost::shared_mutex _lock; }; - typedef IceUtil::Handle<OpenFile> OpenFilePtr; + typedef std::shared_ptr<OpenFile> OpenFilePtr; typedef std::map<int, OpenFilePtr> OpenFiles; public: @@ -104,8 +104,8 @@ namespace NetFS { virtual NetFS::Client::ResourcePtr configureFromUri(const std::string &) const; private: - template<typename Handle> - void setProxy(const Handle &, uint64_t & fh); + template<typename Handle, typename ... Params> + void setProxy(uint64_t & fh, const Params & ...); template<typename Handle> Handle getProxy(uint64_t localID); template<typename Handle> 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 <safeMapFind.h> namespace NetFS { - template<typename Handle> + template<typename Handle, typename ... Params> void - FuseApp::setProxy(const Handle & od, uint64_t & fh) + FuseApp::setProxy(uint64_t & fh, const Params & ... params) { auto & map = getMap<Handle>(); Lock(_lock); while (map.find(fh = ++openHandleId) != map.end()) ; - map.emplace(fh, od); + map.emplace(fh, std::make_shared<typename Handle::element_type>(params...)); } template<typename Handle> 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<OpenDirPtr>(new OpenDir(remote, p), fi->fh); + setProxy<OpenDirPtr>(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<OpenFilePtr>(new OpenFile(remote, p, fi->flags), fi->fh); + setProxy<OpenFilePtr>(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<OpenFilePtr>(new OpenFile(remote, p, fi->flags), fi->fh); + setProxy<OpenFilePtr>(fi->fh, remote, p, fi->flags); return 0; } catch (SystemError & e) { |