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

ruby-concurrency / concurrent-ruby / #2731

10 Jun 2014 02:39PM UTC coverage: 89.322% (-4.3%) from 93.581%
#2731

push

jdantonio
Merge branch 'billdueber-isolated_threadpool_fix'

3 of 3 new or added lines in 1 file covered. (100.0%)

130 existing lines in 12 files now uncovered.

2518 of 2819 relevant lines covered (89.32%)

594.75 hits per line

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

96.97
/lib/concurrent/executor/ruby_single_thread_executor.rb
1
require_relative 'executor'
1✔
2

3
module Concurrent
1✔
4

5
  # @!macro single_thread_executor
6
  class RubySingleThreadExecutor
1✔
7
    include RubyExecutor
1✔
8

9
    # Create a new thread pool.
10
    #
11
    # @see http://docs.oracle.com/javase/tutorial/essential/concurrency/pools.html
12
    # @see http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Executors.html
13
    # @see http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ExecutorService.html
14
    def initialize(opts = {})
1✔
15
      @queue = Queue.new
136✔
16
      @thread = nil
136✔
17
      init_executor
136✔
18
    end
19

20
    protected
1✔
21

22
    # @!visibility private
23
    def execute(*args, &task)
1✔
24
      supervise
333✔
25
      @queue << [args, task]
333✔
26
    end
27

28
    # @!visibility private
29
    def shutdown_execution
1✔
30
      @queue << :stop
16✔
31
      stopped_event.set unless alive?
16✔
32
    end
33

34
    # @!visibility private
35
    def kill_execution
1✔
36
      @queue.clear
36✔
37
      @thread.kill if alive?
36✔
38
    end
39

40
    # @!visibility private
41
    def alive?
1✔
42
      @thread && @thread.alive?
385✔
43
    end
44

45
    # @!visibility private
46
    def supervise
1✔
47
      @thread = new_worker_thread unless alive?
333✔
48
    end
49

50
    # @!visibility private
51
    def new_worker_thread
1✔
52
      Thread.new do
110✔
53
        Thread.current.abort_on_exception = false
93✔
54
        work
93✔
55
      end
56
    end
57

58
    # @!visibility private
59
    def work
1✔
60
      loop do
93✔
61
        task = @queue.pop
187✔
62
        break if task == :stop
142✔
63
        begin
64
          task.last.call(*task.first)
132✔
65
        rescue => ex
66
          # let it fail
UNCOV
67
          log DEBUG, ex
×
68
        end
69
      end
70
      stopped_event.set
10✔
71
    end
72
  end
73
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