#parallel #cross-platform #thread #performance

protex

ProTex (Process Mutex) concurrency in process level

4 releases

new 0.1.3 Sep 13, 2024
0.1.2 Sep 12, 2024
0.1.1 Sep 12, 2024
0.1.0 Sep 12, 2024

#481 in Concurrency

Download history

110 downloads per month

MIT license

14KB
291 lines

ProTex : Process Mutex

  • this project aims to bring concurrency style like std::sync::Mutex for processes well it can be used for multithreading too
  • for more information refer to https://docs.rs/protex/latest/protex/

Getting started

https://crates.io/crates/protex


lib.rs:

for multi threading applications we need a way to bring concurrency to the application . sometimes we want multiple applications be concurrent there are several ways to achieve this goal . this crate tries to be simple , fast and cross platform concurrency Mutex like way to bring concurrency not even for multi threaded apps but also multi process apps so its named Protex (Process Mutex) . this crate must work on Android , iOS , Windows and All Unix like platforms

this simple crate only exports two structs Protex and ProtexGuard .

Protex has new , unlock and remove methods on all the supported platforms . protex::Protex::new(std::ffi::CString , u32) , creates new instance of Protex type with assigned name . this name is used by other processes to find the same Protex instance so think of it as ID . (tested name formats are "/smth") and u32 type which registers the max number of threads which can lock the Protex at same time . after creating Protex instance you can use unlock method which returns ProtexGuard and when it goes out of the scope unlock is released . but remove method is must be called from your main process to remove the Protex instance , if your app crashes for any reason protex instance will remain valid on the system on Unix like systems . so if you wont need it anymore on the starting point of your processes consider creating and removing the instance of Protex .

lock error codes meaning : error -2 = Protex instance is not intialized . error -1 = there was problem with instance of Protex .

Dependencies

~0–35MB
~527K SLoC