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

jdantonio / concurrent-ruby / #748

24 Apr 2014 12:31AM UTC coverage: 78.31% (-19.5%) from 97.805%
#748

push

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

1928 of 2462 relevant lines covered (78.31%)

409.47 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
258✔
11
      @parent = parent
258✔
12
      @mutex = Mutex.new
258✔
13
      @last_activity = Time.now.to_f
258✔
14
    end
15

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

23
    # @!visibility private
24
    def last_activity
1✔
25
      @mutex.synchronize { @last_activity }
8✔
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
230✔
46
        raise StandardError.new('already running') unless @thread.nil?
230✔
47
        @thread = thread
230✔
48
      end
49

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

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