Skip to content

Commit 73496e7

Browse files
committed
Deprecated timer and timeout functions.
1 parent a39941f commit 73496e7

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

lib/concurrent/utility/timeout.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ module Concurrent
2020
# @see http://ruby-doc.org/stdlib-2.2.0/libdoc/timeout/rdoc/Timeout.html Ruby Timeout::timeout
2121
#
2222
# @!macro monotonic_clock_warning
23+
#
24+
# @deprecated timeout is deprecated and will be removed
2325
def timeout(seconds, &block)
2426
warn '[DEPRECATED] timeout is deprecated and will be removed'
2527

lib/concurrent/utility/timer.rb

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
require 'concurrent/configuration'
2-
require 'thread'
32

43
module Concurrent
54

6-
# Perform the given operation asynchronously after the given number of seconds.
7-
#
8-
# This is a convenience method for posting tasks to the global timer set.
9-
# It is intended to be simple and easy to use. For greater control use
10-
# either `TimerSet` or `ScheduledTask` directly.
5+
# [DEPRECATED] Perform the given operation asynchronously after
6+
# the given number of seconds.
117
#
128
# @param [Fixnum] seconds the interval in seconds to wait before executing the task
139
#
@@ -16,10 +12,10 @@ module Concurrent
1612
# @return [Concurrent::ScheduledTask] IVar representing the task
1713
#
1814
# @see Concurrent::ScheduledTask
19-
# @see Concurrent::TimerSet
2015
#
21-
# @!macro monotonic_clock_warning
16+
# @deprecated use `ScheduledTask` instead
2217
def timer(seconds, *args, &block)
18+
warn '[DEPRECATED] use ScheduledTask instead'
2319
raise ArgumentError.new('no block given') unless block_given?
2420
raise ArgumentError.new('interval must be greater than or equal to zero') if seconds < 0
2521
Concurrent.configuration.global_timer_set.post(seconds, *args, &block)

spec/concurrent/utility/timeout_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Concurrent
22

3-
describe '#timeout' do
3+
describe '#timeout', notravis: true do
44

55
it 'raises an exception if no block is given' do
66
expect { Concurrent::timeout(0.1) }.to raise_error

spec/concurrent/utility/timer_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Concurrent
22

3-
describe '#timer' do
3+
describe '#timer', notravis: true do
44

55
it 'raises an exception when no block given' do
66
expect {

0 commit comments

Comments
 (0)