Project

General

Profile

Bug #13941 ยป test.rb

Test script - graywolf (Gray Wolf), 09/26/2017 12:10 AM

 
1
#!/usr/bin/env ruby
2

    
3
require 'thread'
4

    
5
def beat_thread
6
  $stop = false
7
  bt = Thread.new do
8
    loop do
9
      print "."
10
      sleep 0.25
11
      break if $stop
12
    end
13
  end
14
  yield
15
  $stop = true
16
  bt.join
17
end
18

    
19
puts "File exist?:"
20
beat_thread { File.exist? 'blocking_dir/file54' }
21

    
22
puts
23

    
24
puts "File read:"
25
beat_thread { File.read 'blocking_dir/file54' }