Skip to content

Getting Started

This guide walks you through installing and setting up File-Based Semaphore.

Prerequisites

  • Rust 1.70+ (for building from source)
  • Unix/Windows system with filesystem access

Installation

bash
# Clone the repository
git clone https://github.com/tuulbelt/file-based-semaphore.git
cd file-based-semaphore

# Build release binary
cargo build --release

# Binary is at: target/release/sema
./target/release/sema --version

As a Rust Library

Add to your Cargo.toml:

toml
[dependencies]
file-based-semaphore = { git = "https://github.com/tuulbelt/file-based-semaphore.git" }

Quick Verification

bash
# Create a test lock
./target/release/sema try /tmp/test.lock
# Output: Lock acquired: /tmp/test.lock

# Check status
./target/release/sema status /tmp/test.lock
# Output: Lock status: LOCKED

# Release it
./target/release/sema release /tmp/test.lock
# Output: Lock released: /tmp/test.lock

Running Tests

bash
cargo test
# 85 tests should pass

cargo clippy -- -D warnings
# Zero warnings required

Project Structure

file-based-semaphore/
├── Cargo.toml          # Package manifest
├── src/
│   ├── lib.rs          # Library implementation
│   └── main.rs         # CLI implementation
├── tests/
│   └── integration.rs  # Integration tests
├── examples/
│   ├── basic.rs        # Basic usage example
│   └── concurrent.rs   # Concurrent access example
├── README.md           # Documentation
├── SPEC.md             # Protocol specification
└── LICENSE             # MIT license

Next Steps

Released under the MIT License.