1#ifndef NEFORCE_CORE_FILE_FILE_LOCKER_HPP__
2#define NEFORCE_CORE_FILE_FILE_LOCKER_HPP__
21NEFORCE_BEGIN_NAMESPACE__
107 file_lock* lock_out =
nullptr) const noexcept;
143 bool locked_ =
false;
171 NEFORCE_NODISCARD
bool is_locked() const noexcept {
return locked_; }
185NEFORCE_END_NAMESPACE__
bool is_locked() const noexcept
检查是否持有锁
bool unlock() noexcept
手动释放锁
~file_lock_guard()
析构函数,自动释放锁
file_lock_guard(file_locker &locker, difference_type offset, difference_type length, file_lock mode)
构造函数,立即获取锁
file_locker::difference_type difference_type
偏移量类型
bool unlock(difference_type offset, difference_type length) const noexcept
解锁文件区域
int64_t difference_type
偏移量类型
_NEFORCE native_handle_type native_handle_type
原生文件句柄类型
bool lock_whole(file_lock mode=file_lock::EXCLUSIVE) const noexcept
锁定整个文件
bool lock(difference_type offset, difference_type length, file_lock mode=file_lock::EXCLUSIVE) const noexcept
锁定文件区域
bool try_lock(difference_type offset, difference_type length, file_lock mode) const noexcept
尝试锁定
bool is_locked(difference_type offset, difference_type length, file_lock *lock_out=nullptr) const noexcept
查询区域是否被锁定
bool unlock_whole() const noexcept
解锁整个文件
file_locker(native_handle_type handle) noexcept
构造函数