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

jdantonio / concurrent-ruby / #714

23 May 2014 08:08PM UTC coverage: 40.697% (-56.5%) from 97.237%
#714

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%)

1432 existing lines in 56 files now uncovered.

1028 of 2526 relevant lines covered (40.7%)

0.53 hits per line

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

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

3
module Concurrent
1✔
4

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

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

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

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

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

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

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

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

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