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

jdantonio / concurrent-ruby / #716

23 May 2014 08:08PM UTC coverage: 80.966% (-16.3%) from 97.237%
#716

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

469 existing lines in 32 files now uncovered.

2280 of 2816 relevant lines covered (80.97%)

592.71 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
5,322✔
13
      @last_activity = Time.now.to_f
5,322✔
14
    end
5,322✔
15

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

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

1,282✔
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
5,007✔
48
      end
5,007✔
49

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

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