The version of the gem for this specification.
Make sure the trust directory exists. If it does exist, make sure it’s actually a directory. If not, then create it with the appropriate permissions.
We don’t need to download an installed gem
Invoked by Kernel#sleep
and Mutex#sleep and is expected to provide an implementation of sleeping in a non-blocking way. Implementation might register the current fiber in some list of “which fiber wait until what moment”, call Fiber.yield
to pass control, and then in close
resume the fibers whose wait period has elapsed.
Invoked by Timeout.timeout
to execute the given block
within the given duration
. It can also be invoked directly by the scheduler or user code.
Attempt to limit the execution time of a given block
to the given duration
if possible. When a non-blocking operation causes the block
‘s execution time to exceed the specified duration
, that non-blocking operation should be interrupted by raising the specified exception_class
constructed with the given exception_arguments
.
General execution timeouts are often considered risky. This implementation will only interrupt non-blocking operations. This is by design because it’s expected that non-blocking operations can fail for a variety of unpredictable reasons, so applications should already be robust in handling these conditions and by implication timeouts.
However, as a result of this design, if the block
does not invoke any non-blocking operations, it will be impossible to interrupt it. If you desire to provide predictable points for timeouts, consider adding +sleep(0)+.
If the block is executed successfully, its result will be returned.
The exception will typically be raised using Fiber#raise
.
Like Enumerable#filter_map
, but chains operation to be lazy-evaluated.
(1..).lazy.filter_map { |i| i * 2 if i.even? }.first(5) #=> [4, 8, 12, 16, 20]
Like Enumerable#slice_after
, but chains operation to be lazy-evaluated.
Like Enumerable#map
, but chains operation to be lazy-evaluated.
(1..Float::INFINITY).lazy.map {|i| i**2 } #=> #<Enumerator::Lazy: #<Enumerator::Lazy: 1..Infinity>:map> (1..Float::INFINITY).lazy.map {|i| i**2 }.first(3) #=> [1, 4, 9]
Like Enumerable#map
, but chains operation to be lazy-evaluated.
(1..Float::INFINITY).lazy.map {|i| i**2 } #=> #<Enumerator::Lazy: #<Enumerator::Lazy: 1..Infinity>:map> (1..Float::INFINITY).lazy.map {|i| i**2 }.first(3) #=> [1, 4, 9]
Like Enumerable#select
, but chains operation to be lazy-evaluated.
Like Enumerable#reject
, but chains operation to be lazy-evaluated.
Like Enumerable#grep
, but chains operation to be lazy-evaluated.
Like Enumerable#grep_v
, but chains operation to be lazy-evaluated.
Like Enumerable#zip
, but chains operation to be lazy-evaluated. However, if a block is given to zip, values are enumerated immediately.
Like Enumerable#take
, but chains operation to be lazy-evaluated.