[][src]Function padlock::rw_write_lock

pub fn rw_write_lock<T, F, R>(l: &RwLock<T>, f: F) -> R where
    F: FnOnce(&mut T) -> R, 

Aquire a RwLock write lock, passing the lock to the lambda. The lock is released when the lambda finishes. This function returns whatever the lambda returns, allowing you to extract data from a lock without having to worry about releasing the lock.

Read:

This example is not tested
let extracted = padlock::rw_write_lock(&arc_mutex_var, |lock| lock.clone());

Write:

This example is not tested
padlock::rw_write_lock(&arc_mutex_var, |lock| *lock = new_value);