Installation and subsequent safe removal of flock
locks for data streams.
```rust use cluFlock::ToFlock; use std::fs::File; use std::io;
fn main() -> Result<(), io::Error> { let filelock = File::create("./file")?.waitexclusivelock()?; println!("{:?}", filelock);
Ok( () )
} ```
```rust use std::io::Write; use cluFlock::ToFlock; use std::fs::File; use std::io;
fn main() -> Result<(), io::Error> { File::create("./file")?.waitexclusivelock_fn(|mut file| { write!(file, "Test.") })??;
Ok( () )
} ```
```rust use cluFlock::ExclusiveFlock; use std::fs::File;
fn main() -> Result<(), std::io::Error> { let file = File::create("./file")?;
{
let file_lock = ExclusiveFlock::wait_lock(&file)?;
//lock...
println!("{:?}", file_lock);
}
file.sync_all()?;
Ok( () )
} ```
```rust use std::fs::File; use cluFlock::SharedFlock; use std::io;
fn main() -> Result<(), io::Error> { let file = File::create("./file")?;
let shared = SharedFlock::wait_lock(&file);
println!("#1shared {:?}", shared);
let shared2 = SharedFlock::try_lock(&file)?;
println!("#2shared {:?}", shared2);
Ok( () )
} ```
Copyright 2019 #UlinProject Denis Kotlyarov (Денис Котляров)
Licensed under the Apache License, Version 2.0