flexible-locks_derive 0.1.0

Custom Derive for Flexible Locks
Documentation
  • Coverage
  • 0%
    0 out of 2 items documented0 out of 1 items with examples
  • Size
  • Source code size: 7 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 280.9 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 3s Average build duration of successful builds.
  • all releases: 3s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • glandium/flexible-locks
    3 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • glandium

Custom Derive for Flexible Locks

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.

Examples

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,
}