1 个不稳定版本

0.1.0 2022年2月9日

#1248文件系统

Download history 63/week @ 2024-03-11 80/week @ 2024-03-18 83/week @ 2024-03-25 131/week @ 2024-04-01 66/week @ 2024-04-08 95/week @ 2024-04-15 104/week @ 2024-04-22 80/week @ 2024-04-29 86/week @ 2024-05-06 95/week @ 2024-05-13 65/week @ 2024-05-20 73/week @ 2024-05-27 176/week @ 2024-06-03 82/week @ 2024-06-10 71/week @ 2024-06-17 63/week @ 2024-06-24

每月402次下载
sheldon 中使用

MIT/Apache 许可

7KB
79

fmutex

Crates.io Version Docs.rs Latest

使用 flock(2) 提供文件上的互斥锁。

用法

lock()

{
    let _guard = fmutex::lock(path)?;

    // do mutually exclusive stuff here

} // <-- `_guard` dropped here and the lock is released

try_lock()

match fmutex::try_lock(path)? {
    Some(_guard) => {

        // do mutually exclusive stuff here

    } // <-- `_guard` dropped here and the lock is released

    None => {
        eprintln!("warn: the lock could not be acquired!");
    }
}

许可证

许可协议为以下之一:

任选其一。

依赖关系

~43KB