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

ruby-concurrency / concurrent-ruby / #2883

11 Aug 2014 02:52PM UTC coverage: 45.162% (-45.5%) from 90.623%
#2883

push

jdantonio
Removed Rbx from Travis allowed failures list.

1363 of 3018 relevant lines covered (45.16%)

0.66 hits per line

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

58.82
/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
    include SerialExecutor
1✔
9

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

21
    protected
1✔
22

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

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

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

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

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

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

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