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

ruby-concurrency / concurrent-ruby / #2851

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

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

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✔
12
      @task = task
×
13
      @mutex = Mutex.new
×
14
      @exception_class = opts.fetch(:rescue_exception, false) ? Exception : StandardError
×
15
    end
16

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

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

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