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

ruby-concurrency / concurrent-ruby / #2938

11 Aug 2014 02:52PM UTC coverage: 45.217% (-45.4%) from 90.621%
#2938

push

jdantonio
Removed Rbx from Travis allowed failures list.

1366 of 3021 relevant lines covered (45.22%)

0.66 hits per line

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

29.73
/lib/concurrent/executor/ruby_thread_pool_worker.rb
1
require 'thread'
1✔
2
require 'concurrent/logging'
1✔
3

4
module Concurrent
1✔
5

6
  # @!visibility private
7
  class RubyThreadPoolWorker
1✔
8
    include Logging
1✔
9

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

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

25
    # @!visibility private
26
    def last_activity
1✔
27
      @mutex.synchronize { @last_activity }
×
28
    end
29

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

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

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

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

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