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

ruby-concurrency / concurrent-ruby / #2835

05 Oct 2014 10:16PM UTC coverage: 45.201% (-49.6%) from 94.81%
#2835

push

jdantonio
Merge pull request #158 from obrok/promise-composition

Promise composition

2 of 15 new or added lines in 1 file covered. (13.33%)

1514 existing lines in 84 files now uncovered.

1375 of 3042 relevant lines covered (45.2%)

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✔
UNCOV
12
      @queue = queue
×
UNCOV
13
      @parent = parent
×
UNCOV
14
      @mutex = Mutex.new
×
UNCOV
15
      @last_activity = Time.now.to_f
×
16
    end
17

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

25
    # @!visibility private
26
    def last_activity
1✔
UNCOV
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✔
UNCOV
39
      @mutex.synchronize do
×
UNCOV
40
        Thread.kill(@thread) unless @thread.nil?
×
UNCOV
41
        @thread = nil
×
42
      end
43
    end
44

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

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

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