Expand description
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 .
Structs§
- Protex
- ProTex (process mutex) is used to bring concurrency to multi processing well it can be used for multithreading too
- Protex
Guard - it will release the ProTex when it goes out of the scope automatically