tlopo-futex 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +62 -13
- data/lib/tlopo/futex/version.rb +1 -1
- data/lib/tlopo/futex.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ec8a84e0e591eb7b334bb93e18ea64b461897df65ba32bedeca4559e66df78f
|
4
|
+
data.tar.gz: ed879b97b4bce2c9c2fa8f4a3fc825d442dc4ed6b30a57d6df0119ba5576f2c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15ed9bb3c7f84b18030f7f5c54ba03ecc88913f98e2249ba7efd14927ea38c9dff0f269643eb199600c9a92524ef1b7fa2813fab9abd892844643c2e7b07d6b1
|
7
|
+
data.tar.gz: 332b4abe57e58d430c7df7b0cdfa3a8a370341ebf6ad2cbb275b3bbff38adc2cc4bcbd6354dfc5c7b891cf3faadc9c77bf6f9dfef4842233d579b8ea04b01ac1
|
data/README.md
CHANGED
@@ -1,34 +1,83 @@
|
|
1
|
-
#
|
1
|
+
# TLOPO-Futex
|
2
2
|
|
3
|
-
|
3
|
+
**tlopo-futex** is a Ruby gem providing a simple interface for file-based locking. It enables mutual exclusion between processes to ensure safe access to shared resources.
|
4
4
|
|
5
|
-
|
5
|
+
## Features
|
6
|
+
|
7
|
+
- File-based locking mechanism
|
8
|
+
- `lock`, `release`, and `synchronize` methods for efficient, non-blocking resource handling
|
9
|
+
- Lightweight and reliable
|
6
10
|
|
7
11
|
## Installation
|
8
12
|
|
9
|
-
|
13
|
+
Add this line to your Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'tlopo-futex'
|
17
|
+
```
|
10
18
|
|
11
|
-
|
19
|
+
Then run:
|
12
20
|
|
13
|
-
|
21
|
+
```bash
|
22
|
+
bundle install
|
23
|
+
```
|
14
24
|
|
15
|
-
|
25
|
+
Or install directly with:
|
16
26
|
|
17
|
-
|
27
|
+
```bash
|
28
|
+
gem install tlopo-futex
|
29
|
+
```
|
18
30
|
|
19
31
|
## Usage
|
20
32
|
|
21
|
-
|
33
|
+
### Basic Lock and Unlock Example
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
require 'tlopo/futex'
|
37
|
+
|
38
|
+
# Initialize the lock with a path to a lock file
|
39
|
+
lock = Tlopo::Futex.new('/tmp/my_lock_file')
|
40
|
+
|
41
|
+
# Lock, execute critical code, then release
|
42
|
+
lock.lock
|
43
|
+
# Critical section code goes here
|
44
|
+
lock.release
|
45
|
+
```
|
46
|
+
|
47
|
+
### Checking Lock Status
|
48
|
+
|
49
|
+
You can check if the lock is currently active:
|
22
50
|
|
23
|
-
|
51
|
+
```ruby
|
52
|
+
if lock.locked?
|
53
|
+
puts "Resource is locked by another process"
|
54
|
+
else
|
55
|
+
lock.lock
|
56
|
+
# Critical section code
|
57
|
+
lock.release
|
58
|
+
end
|
59
|
+
```
|
24
60
|
|
25
|
-
|
61
|
+
### Using `synchronize` for Automatic Locking
|
26
62
|
|
27
|
-
|
63
|
+
The `synchronize` method locks and releases automatically, ensuring that the lock is properly released even if an error occurs.
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
lock.synchronize do
|
67
|
+
# Critical section code that needs exclusive access
|
68
|
+
end
|
69
|
+
```
|
70
|
+
|
71
|
+
## Contributing
|
72
|
+
|
73
|
+
Bug reports and pull requests are welcome on GitHub at [https://github.com/tlopo-ruby/tlopo-futex](https://github.com/tlopo-ruby/tlopo-futex).
|
74
|
+
|
75
|
+
## License
|
28
76
|
|
77
|
+
This gem is available under the MIT License.
|
29
78
|
## Contributing
|
30
79
|
|
31
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
80
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/tlopo-ruby/tlopo-futex. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/tlopo-ruby/tlopo-futex/blob/main/CODE_OF_CONDUCT.md).
|
32
81
|
|
33
82
|
## License
|
34
83
|
|
data/lib/tlopo/futex/version.rb
CHANGED
data/lib/tlopo/futex.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tlopo-futex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tlopo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-10-
|
11
|
+
date: 2024-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: File based mutual exclusive lock
|
14
14
|
email:
|