cmFileLockPool: enhance items management

This commit is contained in:
Marc Chevrier
2019-11-12 17:17:27 +01:00
parent aeb95264e0
commit 8dd284bf19
5 changed files with 62 additions and 33 deletions

View File

@@ -3,11 +3,23 @@
#include "cmFileLock.h"
#include <cassert>
#include <utility>
#include "cmFileLockResult.h"
// Common implementation
cmFileLock::cmFileLock(cmFileLock&& other) noexcept
{
this->File = other.File;
#if defined(_WIN32)
other.File = INVALID_HANDLE_VALUE;
#else
other.File = -1;
#endif
this->Filename = std::move(other.Filename);
}
cmFileLock::~cmFileLock()
{
if (!this->Filename.empty()) {
@@ -17,6 +29,19 @@ cmFileLock::~cmFileLock()
}
}
cmFileLock& cmFileLock::operator=(cmFileLock&& other) noexcept
{
this->File = other.File;
#if defined(_WIN32)
other.File = INVALID_HANDLE_VALUE;
#else
other.File = -1;
#endif
this->Filename = std::move(other.Filename);
return *this;
}
cmFileLockResult cmFileLock::Lock(const std::string& filename,
unsigned long timeout)
{