process_shared 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
@@ -198,6 +198,7 @@ module ProcessShared
|
|
198
198
|
def read(length = nil, buffer = nil)
|
199
199
|
length ||= (mem.size - pos)
|
200
200
|
buffer ||= ''
|
201
|
+
buffer.force_encoding('ASCII-8BIT') unless RUBY_VERSION.start_with?('1.8')
|
201
202
|
|
202
203
|
actual_length = [(mem.size - pos), length].min
|
203
204
|
actual_length.times do
|
@@ -63,5 +63,19 @@ module ProcessShared
|
|
63
63
|
(Time.now.to_f - start).must be_gte(0.1)
|
64
64
|
}
|
65
65
|
end
|
66
|
+
|
67
|
+
it 'correctly handles #signal when no waiters' do
|
68
|
+
mutex = Mutex.new
|
69
|
+
cond = ConditionVariable.new
|
70
|
+
|
71
|
+
# fix for bug: #wait not waiting after unmatched call to #signal
|
72
|
+
cond.signal
|
73
|
+
|
74
|
+
mutex.synchronize {
|
75
|
+
start = Time.now.to_f
|
76
|
+
cond.wait(mutex, 0.1)
|
77
|
+
(Time.now.to_f - start).must be_gte(0.1)
|
78
|
+
}
|
79
|
+
end
|
66
80
|
end
|
67
81
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# ^^^
|
3
|
+
# NOTE: This magic comment is necessary for the UTF-8 string literal below
|
4
|
+
# on Ruby 1.9.x
|
5
|
+
require 'spec_helper'
|
6
|
+
require 'process_shared'
|
7
|
+
|
8
|
+
module ProcessShared
|
9
|
+
describe SharedMemoryIO do
|
10
|
+
|
11
|
+
describe '#read' do
|
12
|
+
def binary(s)
|
13
|
+
(RUBY_VERSION == '1.8.7') ? s : s.force_encoding('ASCII-8BIT')
|
14
|
+
end
|
15
|
+
|
16
|
+
def output_for(input)
|
17
|
+
mem = SharedMemory.new(16)
|
18
|
+
mem.put_bytes(0, input, 0, input.bytesize)
|
19
|
+
io = SharedMemoryIO.new(mem)
|
20
|
+
io.read(input.bytesize)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'returns correct binary data for plain ASCII string' do
|
24
|
+
input = 'Hello'
|
25
|
+
output_for(input).must_equal binary(input)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'returns correct binary data for UTF-8 string' do
|
29
|
+
input = 'Mária'
|
30
|
+
output_for(input).must_equal binary(input)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'returns correct binary data for explicitly binary data' do
|
34
|
+
input = "\x00\xD1\x9B\x86\x00"
|
35
|
+
output_for(input).must_equal binary(input)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
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.1.
|
4
|
+
version: 0.1.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -201,6 +201,7 @@ files:
|
|
201
201
|
- spec/mach/scratch2.rb
|
202
202
|
- spec/mach/scratch.rb
|
203
203
|
- spec/process_shared/shared_memory_spec.rb
|
204
|
+
- spec/process_shared/shared_memory_io_spec.rb
|
204
205
|
- spec/process_shared/lock_behavior.rb
|
205
206
|
- spec/process_shared/binary_semaphore_spec.rb
|
206
207
|
- spec/process_shared/shared_array_spec.rb
|
@@ -226,7 +227,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
226
227
|
version: '0'
|
227
228
|
segments:
|
228
229
|
- 0
|
229
|
-
hash: -
|
230
|
+
hash: -288015031839380416
|
230
231
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
231
232
|
none: false
|
232
233
|
requirements:
|
@@ -235,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
235
236
|
version: '0'
|
236
237
|
segments:
|
237
238
|
- 0
|
238
|
-
hash: -
|
239
|
+
hash: -288015031839380416
|
239
240
|
requirements: []
|
240
241
|
rubyforge_project:
|
241
242
|
rubygems_version: 1.8.23
|