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

jdantonio / concurrent-ruby / #740

23 May 2014 08:08PM UTC coverage: 81.072% (-16.2%) from 97.237%
#740

push

jdantonio
Merge pull request #96 from jdantonio/refactor/errors

Moved all custom errors into a single file and into the Concurrent module

17 of 18 new or added lines in 10 files covered. (94.44%)

466 existing lines in 32 files now uncovered.

2283 of 2816 relevant lines covered (81.07%)

472.41 hits per line

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

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

1✔
3
module Concurrent
4

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

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

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

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

204✔
28
    def status
29
      @mutex.synchronize do
30
        return 'not running' if @thread.nil?
1✔
31
        @thread.status
×
UNCOV
32
      end
×
UNCOV
33
    end
×
34

35
    # @!visibility private
36
    def kill
37
      @mutex.synchronize do
38
        Thread.kill(@thread) unless @thread.nil?
1✔
UNCOV
39
        @thread = nil
×
UNCOV
40
      end
×
UNCOV
41
    end
×
42

43
    # @!visibility private
44
    def run(thread = Thread.current)
45
      @mutex.synchronize do
46
        raise StandardError.new('already running') unless @thread.nil?
1✔
47
        @thread = thread
194✔
48
      end
194✔
49

194✔
50
      loop do
51
        task = @queue.pop
52
        if task == :stop
194✔
53
          @thread = nil
3,688✔
54
          @parent.on_worker_exit(self)
3,498✔
UNCOV
55
          break
×
UNCOV
56
        end
×
UNCOV
57

×
58
        begin
59
          task.last.call(*task.first)
60
        rescue => ex
61
          # let it fail
3,498✔
62
        ensure
63
          @last_activity = Time.now.to_f
UNCOV
64
          @parent.on_end_task
×
65
        end
66
      end
3,498✔
67
    end
3,498✔
68
  end
69
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