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

jdantonio / concurrent-ruby / #812

23 May 2014 08:08PM UTC coverage: 39.344% (-57.9%) from 97.237%
#812

push

jdantonio
Merge pull request #96 from jdantonio/refactor/errors

Moved all custom errors into a single file and into the Concurrent module

17 of 18 new or added lines in 10 files covered. (94.44%)

1435 existing lines in 57 files now uncovered.

1187 of 3017 relevant lines covered (39.34%)

0.5 hits per line

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

46.15
/lib/concurrent/utility/timeout.rb
1
require 'rbconfig'
1✔
2
require 'thread'
1✔
3

4
require 'concurrent/errors'
1✔
5

6
module Concurrent
1✔
7

8
  # Wait the given number of seconds for the block operation to complete.
9
  #
10
  # @param [Integer] seconds The number of seconds to wait
11
  #
12
  # @return [Object] The result of the block operation
13
  #
14
  # @raise [Concurrent::TimeoutError] when the block operation does not complete
15
  #   in the allotted number of seconds.
16
  #
17
  # @note This method is intended to be a simpler and more reliable replacement
18
  # to the Ruby standard library `Timeout::timeout` method.
19
  def timeout(seconds)
1✔
20

UNCOV
21
    thread = Thread.new do
×
UNCOV
22
      Thread.current[:result] = yield
×
23
    end
UNCOV
24
    success = thread.join(seconds)
×
25

UNCOV
26
    if success
×
UNCOV
27
      return thread[:result]
×
28
    else
UNCOV
29
      raise TimeoutError
×
30
    end
31
  ensure
UNCOV
32
    Thread.kill(thread) unless thread.nil?
×
33
  end
34
  module_function :timeout
1✔
35
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc