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