|
NexusForce 1.0.0
A Modern C++ Library with extended functionality, web components, and utility libraries
|
文件区域锁管理类 更多...
#include <file_locker.hpp>
Public 类型 | |
| using | native_handle_type = _NEFORCE native_handle_type |
| 原生文件句柄类型 | |
| using | difference_type = int64_t |
| 偏移量类型 | |
Public 成员函数 | |
| file_locker (native_handle_type handle) noexcept | |
| 构造函数 | |
| bool | lock (difference_type offset, difference_type length, file_lock mode=file_lock::EXCLUSIVE) const noexcept |
| 锁定文件区域 | |
| bool | unlock (difference_type offset, difference_type length) const noexcept |
| 解锁文件区域 | |
| bool | try_lock (difference_type offset, difference_type length, file_lock mode) const noexcept |
| 尝试锁定 | |
| NEFORCE_NODISCARD bool | is_locked (difference_type offset, difference_type length, file_lock *lock_out=nullptr) const noexcept |
| 查询区域是否被锁定 | |
| bool | lock_whole (file_lock mode=file_lock::EXCLUSIVE) const noexcept |
| 锁定整个文件 | |
| bool | unlock_whole () const noexcept |
| 解锁整个文件 | |
文件区域锁管理类
对文件句柄提供区域级的锁定与解锁操作:
在文件 file_locker.hpp 第 41 行定义.
|
explicitnoexcept |
|
noexcept |
查询区域是否被锁定
| offset | 起始偏移量 |
| length | 查询长度 |
| lock_out | 如果非空,输出当前持有的锁类型 |
查询指定区域是否被其他进程锁定。
|
noexcept |
锁定文件区域
| offset | 起始偏移量(字节) |
| length | 锁定长度(字节),0表示到文件末尾 |
| mode | 锁定模式 |
阻塞等待直到获得锁。 如果length为0,锁定从offset到文件末尾的所有区域。
引用了 EXCLUSIVE.
|
noexcept |
|
noexcept |
尝试锁定
| offset | 起始偏移量 |
| length | 锁定长度 |
| mode | 锁定模式 |
尝试获取锁,如果锁已被占用则立即返回false,不会阻塞等待。
|
noexcept |
解锁文件区域
| offset | 起始偏移量 |
| length | 解锁长度,0表示到文件末尾 |
释放指定区域的锁。解锁的区域必须与锁定的区域完全匹配。
|
noexcept |