Module: ExecutionDeadline
- Defined in:
- lib/execution_deadline.rb,
lib/execution_deadline/errors.rb,
lib/execution_deadline/helpers.rb,
lib/execution_deadline/version.rb,
lib/execution_deadline/deadline.rb,
lib/execution_deadline/deadliner.rb,
lib/execution_deadline/method_proxy.rb
Defined Under Namespace
Modules: Deadliner, Helpers, MethodProxy
Classes: Deadline, DeadlineError, DeadlineExceeded, OutOfTime
Constant Summary
collapse
- VERSION =
'0.2.1'
Class Method Summary
collapse
Class Method Details
.clear_deadline! ⇒ Object
11
12
13
|
# File 'lib/execution_deadline.rb', line 11
def self.clear_deadline!
Thread.current[:deadline] = nil
end
|
.current_deadline ⇒ Object
7
8
9
|
# File 'lib/execution_deadline.rb', line 7
def self.current_deadline
Thread.current[:deadline]
end
|
.extended(other) ⇒ Object
24
25
26
|
# File 'lib/execution_deadline.rb', line 24
def self.extended(other)
other.extend(Helpers)
end
|
.included(other) ⇒ Object
28
29
30
|
# File 'lib/execution_deadline.rb', line 28
def self.included(other)
other.extend(Helpers)
end
|
.set_deadline(expires_at:, raises: nil) ⇒ Boolean|Deadline
Returns false if a deadline is already set, and returns a deadline object if it was successfully set
19
20
21
22
|
# File 'lib/execution_deadline.rb', line 19
def self.set_deadline(expires_at:, raises: nil)
!current_deadline &&
Thread.current[:deadline] = Deadline.new(expires_at: expires_at, raises: raises)
end
|