• 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

31.25
/lib/concurrent/executor/safe_task_executor.rb
1
require 'thread'
1✔
2

3
module Concurrent
1✔
4

5
  # A simple utility class that executes a callable and returns and array of three elements:
6
  # success - indicating if the callable has been executed without errors
7
  # value - filled by the callable result if it has been executed without errors, nil otherwise
8
  # reason - the error risen by the callable if it has been executed with errors, nil otherwise
9
  class SafeTaskExecutor
1✔
10

11
    def initialize(task, opts = {})
1✔
UNCOV
12
      @task = task
×
UNCOV
13
      @mutex = Mutex.new
×
UNCOV
14
      @exception_class = opts.fetch(:rescue_exception, false) ? Exception : StandardError
×
15
    end
16

17
    # @return [Array]
18
    def execute(*args)
1✔
UNCOV
19
      @mutex.synchronize do
×
UNCOV
20
        success = false
×
UNCOV
21
        value = reason = nil
×
22

23
        begin
UNCOV
24
          value = @task.call(*args)
×
UNCOV
25
          success = true
×
26
        rescue @exception_class => ex
UNCOV
27
          reason = ex
×
UNCOV
28
          success = false
×
29
        end
30

UNCOV
31
        [success, value, reason]
×
32
      end
33
    end
34
  end
35
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