• 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

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 · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc