Skip to content

Commit

Permalink
Avoid auto_ptr if C++11 is available.
Browse files Browse the repository at this point in the history
  • Loading branch information
bbockelm committed Feb 3, 2015
1 parent d395913 commit 1886198
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
11 changes: 9 additions & 2 deletions src/XrdThrottle/XrdThrottle.hh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,15 @@
class XrdSysLogger;
class XrdOucStream;


namespace XrdThrottle {

#if __cplusplus >= 201103L
typedef std::unique_ptr<XrdSfsFile> unique_sfs_ptr;
#else
typedef std::auto_ptr<XrdSfsFile> unique_sfs_ptr;
#endif

class FileSystem;

class File : public XrdSfsFile {
Expand Down Expand Up @@ -86,12 +93,12 @@ public:
XrdSfsXferSize size);

private:
File(const char *user, int monid, std::auto_ptr<XrdSfsFile>, XrdThrottleManager &throttle, XrdSysError &eroute);
File(const char *user, int monid, unique_sfs_ptr, XrdThrottleManager &throttle, XrdSysError &eroute);

virtual
~File();

std::auto_ptr<XrdSfsFile> m_sfs;
unique_sfs_ptr m_sfs;
int m_uid; // A unique identifier for this user; has no meaning except for the fairshare.
std::string m_loadshed;
std::string m_user;
Expand Down
8 changes: 6 additions & 2 deletions src/XrdThrottle/XrdThrottleFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ XrdThrottleTimer xtimer = m_throttle.StartIOTimer();

File::File(const char *user,
int monid,
std::auto_ptr<XrdSfsFile> sfs,
unique_sfs_ptr sfs,
XrdThrottleManager &throttle,
XrdSysError &eroute)
: m_sfs(sfs), // Guaranteed to be non-null by FileSystem::newFile
#if __cplusplus >= 201103L
: m_sfs(std::move(sfs)), // Guaranteed to be non-null by FileSystem::newFile
#else
: m_sfs(sfs),
#endif
m_uid(0),
m_user(user),
m_throttle(throttle),
Expand Down
6 changes: 5 additions & 1 deletion src/XrdThrottle/XrdThrottleFileSystem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ FileSystem::newFile(char *user,
XrdSfsFile * chain_file = m_sfs_ptr->newFile(user, monid);
if (chain_file)
{
std::auto_ptr<XrdSfsFile> chain_file_ptr(chain_file);
unique_sfs_ptr chain_file_ptr(chain_file);
// We should really be giving out shared_ptrs to m_throttle, but alas, no boost.
#if __cplusplus >= 201103L
return static_cast<XrdSfsFile*>(new File(user, monid, std::move(chain_file_ptr), m_throttle, m_eroute));
#else
return static_cast<XrdSfsFile*>(new File(user, monid, chain_file_ptr, m_throttle, m_eroute));
#endif
}
return NULL;
}
Expand Down

0 comments on commit 1886198

Please sign in to comment.