| Crates.io | flexible-locks_derive |
| lib.rs | flexible-locks_derive |
| version | 0.1.0 |
| created_at | 2018-04-28 00:57:00.051528+00 |
| updated_at | 2018-04-28 00:57:00.051528+00 |
| description | Custom Derive for Flexible Locks |
| homepage | |
| repository | https://github.com/glandium/flexible-locks |
| max_upload_size | |
| id | 62687 |
| size | 6,429 |
This crate provides custom derives for traits describing types that can be wrapped in Flexible Locks types.
For now, Flexible Locks only provides a Mutex type, so this crate provides
a #[derive(MutexProtected)].
The #[mutex] attribute is used to indicate the data field containing the raw
mutex type.
extern crate flexible_locks;
#[macro_use]
extern crate flexible_locks_derive;
use flexible_locks::{Mutex, RawMutex};
// Pick your choice of raw mutex;
#[cfg(windows)]
use flexible_locks::CRITICAL_SECTION as RawOsMutex;
#[cfg(unix)]
use flexible_locks::pthread_mutex_t as RawOsMutex;
#[derive(MutexProtected)]
struct Data {
a: usize,
#[mutex]
mutex: RawOsMutex,
b: usize,
}