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

ruby-concurrency / concurrent-ruby / #2777

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

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

77.78
/lib/concurrent/executor/immediate_executor.rb
1
require 'concurrent/atomic/event'
1✔
2
require 'concurrent/executor/executor'
1✔
3

4
module Concurrent
1✔
5

6
  # An executor service which runs all operations on the current thread,
7
  # blocking as necessary. Operations are performed in the order they are
8
  # received and no two operations can be performed simultaneously.
9
  #
10
  # This executor service exists mainly for testing an debugging. When used
11
  # it immediately runs every `#post` operation on the current thread, blocking
12
  # that thread until the operation is complete. This can be very beneficial
13
  # during testing because it makes all operations deterministic.
14
  #
15
  # @note Intended for use primarily in testing and debugging.
16
  class ImmediateExecutor
1✔
17
    include SerialExecutor
1✔
18

19
    # Creates a new executor
20
    def initialize
1✔
21
      @stopped = Concurrent::Event.new
2✔
22
    end
23

24
    # @!macro executor_method_post
25
    def post(*args, &task)
1✔
26
      raise ArgumentError.new('no block given') unless block_given?
4✔
27
      return false unless running?
4✔
28
      task.call(*args)
4✔
29
      true
4✔
30
    end
31

32
    # @!macro executor_method_left_shift
33
    def <<(task)
1✔
UNCOV
34
      post(&task)
×
UNCOV
35
      self
×
36
    end
37

38
    # @!macro executor_method_running_question
39
    def running?
1✔
40
      ! shutdown?
4✔
41
    end
42

43
    # @!macro executor_method_shuttingdown_question
44
    def shuttingdown?
1✔
45
      false
×
46
    end
47

48
    # @!macro executor_method_shutdown_question
49
    def shutdown?
1✔
50
      @stopped.set?
4✔
51
    end
52

53
    # @!macro executor_method_shutdown
54
    def shutdown
1✔
UNCOV
55
      @stopped.set
×
UNCOV
56
      true
×
57
    end
58
    alias_method :kill, :shutdown
1✔
59

60
    # @!macro executor_method_wait_for_termination
61
    def wait_for_termination(timeout = nil)
1✔
UNCOV
62
      @stopped.wait(timeout)
×
63
    end
64
  end
65
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