Skip to content

Commit

Permalink
Merge pull request #2303 from tduehr/ffi_spec_change
Browse files Browse the repository at this point in the history
fix blocking function call spec in ffi
  • Loading branch information
nirvdrum committed Dec 11, 2014
2 parents a560b2e + c7e89ec commit 540b635
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions spec/ffi/function_spec.rb
Expand Up @@ -63,12 +63,15 @@ class << self; self; end
end

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.each { |t| t.join }
fp = FFI::Function.new(:void, [ :int ], @libtest.find_function('testBlocking'), :blocking => true)
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

it 'autorelease flag is set to true by default' do
Expand Down

0 comments on commit 540b635

Please sign in to comment.