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

jdantonio / concurrent-ruby / #715

24 Apr 2014 12:31AM UTC coverage: 78.067% (-19.7%) from 97.805%
#715

push

jdantonio
Attempting to fix a brittle test of Concurrent::timer.

1922 of 2462 relevant lines covered (78.07%)

560.95 hits per line

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

73.53
/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✔
10
      @queue = queue
7,182✔
11
      @parent = parent
7,182✔
12
      @mutex = Mutex.new
7,182✔
13
      @last_activity = Time.now.to_f
7,182✔
14
    end
15

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

23
    # @!visibility private
24
    def last_activity
1✔
25
      @mutex.synchronize { @last_activity }
256✔
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✔
37
      @mutex.synchronize do
×
38
        Thread.kill(@thread) unless @thread.nil?
×
39
        @thread = nil
×
40
      end
41
    end
42

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

50
      loop do
6,533✔
51
        task = @queue.pop
7,873✔
52
        if task == :stop
1,344✔
53
          @thread = nil
×
54
          @parent.on_worker_exit(self)
×
55
          break
×
56
        end
57

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