process_shared 0.2.1b → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +44 -13
  3. metadata +7 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 83d9a90ae2f4158f41b0e0ffc996d978fac0acfc
4
- data.tar.gz: f9ff3cc8f623e99723efcd4150d30f42ea5d8042
3
+ metadata.gz: a23ff1b1fbc2944e69e66f89d2db7dc0210cfd95
4
+ data.tar.gz: d361bd34750fc4ee8f099fbc7d7be73fb753002d
5
5
  SHA512:
6
- metadata.gz: 9b83fe2042d36fd665e0c6558df40037ecd371c6805a920da5eb486b265916a702580c0bd7b411769c617577556f5e5bec0b1b1ca50cc1fa58fea91ee0d1a0b8
7
- data.tar.gz: ffe25c4ca0f8615e81ddf495d00e53e976d6dcd17fb393e14597944c767a7b75a62363817afc755153add83fb35a0390d243c5e4c72e7e8624cba8177308e001
6
+ metadata.gz: f4fd2807a7fa4bf0863ba329a45cc3e05fb3abb74ccd7492dfa53c214bf7493eeb75d3646143e63aee3f8fae484ab162d0ef7cdf4fbfc38f252824f7f878d597
7
+ data.tar.gz: 1079a54be971d445ef46eaa06fd228616668a49a79dfdac25ea56eab111a10b30e75b5dd628aeab1fc5d1401ef82bd0d5526870363cf741791605da5e7f5b3a8
data/README.md CHANGED
@@ -14,26 +14,57 @@
14
14
  process_shared
15
15
  ==============
16
16
 
17
- Concurrency primitives that may be used in a cross-process way to
18
- coordinate share memory between processes.
17
+ Cross-process concurrency primitives that may be used to coordinate
18
+ shared memory between processes.
19
+
20
+ ```ruby
21
+ require 'process_shared'
22
+
23
+ mutex = ProcessShared::Mutex.new
24
+ cond = ProcessShared::ConditionVariable.new
25
+
26
+ mem = ProcessShared::SharedMemory.new(:int32, 2) # extends FFI::Pointer
27
+
28
+ pid1 = fork do
29
+ nums = mutex.synchronize do
30
+ cond.wait(mutex)
31
+ mem.get_array_of_int(0, 2)
32
+ end
33
+ puts "process #{Process.pid} received #{nums}"
34
+ end
35
+
36
+ pid2 = fork do
37
+ nums = [12345, 67890]
38
+ mutex.synchronize do
39
+ puts "process #{Process.pid} sending #{nums}"
40
+ mem.put_array_of_int(0, nums)
41
+ cond.signal
42
+ end
43
+ end
44
+
45
+ Process.waitall
46
+ ```
47
+
48
+ [API Documentation](http://www.rubydoc.info/github/pmahoney/process_shared/master)
19
49
 
20
50
  FFI is used to access POSIX semaphore on Linux or Mach semaphores on
21
- Mac. Atop these semaphores are implemented ProcessShared::Semaphore,
22
- ProcessShared::Mutex. POSIX shared memory is used to implement
23
- ProcessShared::SharedMemory.
51
+ Mac. Atop these semaphores are implemented `ProcessShared::Semaphore`,
52
+ `ProcessShared::Mutex`. POSIX shared memory is used to implement
53
+ `ProcessShared::SharedMemory`.
24
54
 
25
55
  On Linux, POSIX semaphores support `sem_timedwait()` which can wait on
26
56
  a semaphore but stop waiting after a timeout.
27
57
 
28
58
  Mac OS X's implementation of POSIX semaphores does not support
29
- timeouts. But, the Mach layer in Mac OS X has its own semaphores that
30
- do support timeouts. Thus, process_shared implements a moderate
31
- subset of the Mach API, which is quite a bit different from POSIX.
32
- Namely, semaphores created in one process are not available in child
33
- processes created via `fork()`. Mach does provide the means to copy
34
- capabilities between tasks (Mach equivalent to processes).
35
- process_shared overrides Ruby's `fork` methods so that semaphores are
36
- copied from parent to child to emulate the POSIX behavior.
59
+ timeouts. But, the Mach layer in Mac OS X has its own semaphores that
60
+ do support timeouts. Thus, process_shared implements a moderate subset
61
+ of the Mach API, which is quite a bit different from POSIX. Namely,
62
+ semaphores created in one process are not available in child processes
63
+ created via `fork()`. Mach does provide the means to copy capabilities
64
+ between tasks (Mach equivalent to processes). In a giant hack, **on OS
65
+ X, `process_shared` overrides Ruby's `fork`** methods so that
66
+ semaphores are copied from parent to child to emulate the POSIX
67
+ behavior.
37
68
 
38
69
  This is an incomplete work in progress.
39
70
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: process_shared
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1b
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Mahoney
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: ci_reporter_minitest
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '1.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '1.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: flog
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -213,9 +213,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
213
213
  version: '0'
214
214
  required_rubygems_version: !ruby/object:Gem::Requirement
215
215
  requirements:
216
- - - ">"
216
+ - - ">="
217
217
  - !ruby/object:Gem::Version
218
- version: 1.3.1
218
+ version: '0'
219
219
  requirements: []
220
220
  rubyforge_project:
221
221
  rubygems_version: 2.2.0
@@ -223,4 +223,3 @@ signing_key:
223
223
  specification_version: 4
224
224
  summary: process-shared synchronization primitives
225
225
  test_files: []
226
- has_rdoc: true