From c66961af7fcc44121a7d060734d300afd3120419 Mon Sep 17 00:00:00 2001 From: tduehr Date: Wed, 10 Dec 2014 11:03:55 -0600 Subject: fix blocking function spec --- spec/ffi/function_spec.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/spec/ffi/function_spec.rb b/spec/ffi/function_spec.rb index 14fe31c..a17cbbe 100644 --- a/spec/ffi/function_spec.rb +++ b/spec/ffi/function_spec.rb @@ -64,10 +64,13 @@ describe FFI::Function do it 'can wrap a blocking function' do fp = FFI::Function.new(:void, [ :int ], @libtest.find_function('testBlocking'), :blocking => true) - time = Time.now - threads = [] - threads << Thread.new { fp.call(2) } - threads << Thread.new(time) { expect(Time.now - time).to be < 1 } + threads = 10.times.map do |x| + Thread.new do + time = Time.now + fp.call(2) + expect(Time.now - time).to be > 2 + end + end threads.each { |t| t.join } end -- cgit v1.2.1