jthread 0.1.1

Deadlock-free Mutual Exclusion locks for Rust
Documentation
  • Coverage
  • 75%
    12 out of 16 items documented5 out of 11 items with examples
  • Size
  • Source code size: 55.43 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.55 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 11s Average build duration of successful builds.
  • all releases: 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • MovAh13h/jthread-rs
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • MovAh13h

JThread-rs - deadlock-free mutex lock library

JThread is a Rust library designed to facilitate advanced mutex management in multi-threaded environments while providing deadlock-freedom. It provides mutexes with fine-grained control, and custom error handling, tailored for achieving deadlock-freedom.

Features

  • Region and JMutex for advanced mutex locking strategies.
  • Custom error types (JError) for specific mutex and region-related errors.
  • Convenient sync macro for easy and safe locking of one or more mutexes.

Installation

Add this to your Cargo.toml:

[dependencies]
jthread = "0.1.0"

Usage

Lock creation:

use jthread::{JMutex, Region};

let region = Region::new();
let mutex = JMutex::new(5, region); // Protecting an integer

Using the sync macro:

use jthread::{JMutex, sync, Region};

let data_mutex = JMutex::with_default(5); // Protecting an integer
let result = sync!([data_mutex], |data_guard| {
    *data_guard += 1; // Modify the data
    *data_guard
});

Our tests module has the infamous Dining Philosophers problem setup using JThread. Feel free to refer to the variations provided in the module as advanced example usage.

Tests

The library includes a comprehensive test suite demonstrating its capabilities, especially in complex multi-threading scenarios. Refer to the tests module for examples and usage patterns.

Documentation

For more detailed information on each component and method, refer to the inline documentation within the library source code, generated using Rust's standard documentation tool, cargo doc.