• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

jdantonio / concurrent-ruby / #720

06 Apr 2014 10:19PM UTC coverage: 92.699% (-4.6%) from 97.309%
#720

push

chrisseaton
Update README.md

1587 of 1712 relevant lines covered (92.7%)

567.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.94
/lib/concurrent/ruby_thread_pool_worker.rb
1
require 'thread'
1✔
2

3
module Concurrent
1✔
4

5
  # @!visibility private
6
  class RubyThreadPoolWorker # :nodoc:
1✔
7

8
    # @!visibility private
9
    def initialize(queue, parent) # :nodoc:
1✔
10
      @queue = queue
675✔
11
      @parent = parent
675✔
12
      @mutex = Mutex.new
675✔
13
      @last_activity = Time.now.to_f
675✔
14
    end
15

16
    # @!visibility private
17
    def dead? # :nodoc:
1✔
18
      return @mutex.synchronize do
17✔
19
        @thread.nil? ? false : ! @thread.alive?
17✔
20
      end
21
    end
22

23
    # @!visibility private
24
    def last_activity # :nodoc:
1✔
25
      @mutex.synchronize { @last_activity }
28✔
26
    end
27

28
    # @!visibility private
29
    def kill # :nodoc:
1✔
30
      @mutex.synchronize do
×
31
        Thread.kill(@thread) unless @thread.nil?
×
32
        @thread = nil
33
      end
34
    end
35

36
    # @!visibility private
1✔
37
    def run(thread = Thread.current) # :nodoc:
302✔
38
      @mutex.synchronize do
302✔
39
        raise StandardError.new('already running') unless @thread.nil?
302✔
40
        @thread = thread
41
      end
42

43
      loop do
44
        task = @queue.pop
1✔
45
        if task == :stop
647✔
46
          @thread = nil
647✔
47
          @parent.on_worker_exit(self)
647✔
48
          break
49
        end
50

647✔
51
        begin
2,374✔
52
          task.last.call(*task.first)
2,096✔
53
        rescue => ex
265✔
54
          # let it fail
265✔
55
        ensure
265✔
56
          @last_activity = Time.now.to_f
57
          @parent.on_end_task
58
        end
59
      end
1,831✔
60
    end
61
  end
62
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc