Sha256: 3af90fa4f4122fb63cda0041cb634164f8412128b9a18ce8b1aaaa72de318f6c

Contents?: true

Size: 634 Bytes

Versions: 20

Compression:

Stored size: 634 Bytes

Contents

require 'concurrent/maybe'
require 'concurrent/utility/monotonic_time'

module Concurrent
  class Channel
    class Selector

      class AfterClause

        def initialize(seconds, block)
          raise ArgumentError.new('timeout must 0.0 or more') if seconds.to_f < 0.0
          @end = Concurrent.monotonic_time + seconds.to_f
          @block = block
        end

        def execute
          if Concurrent.monotonic_time > @end
            result = @block ? @block.call : nil
            Concurrent::Maybe.just(result)
          else
            Concurrent::Maybe.nothing
          end
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
concurrent-ruby-edge-0.7.2 lib/concurrent-ruby-edge/concurrent/channel/selector/after_clause.rb
concurrent-ruby-edge-0.7.1 lib/concurrent-ruby-edge/concurrent/channel/selector/after_clause.rb
concurrent-ruby-edge-0.7.0 lib/concurrent-ruby-edge/concurrent/channel/selector/after_clause.rb
concurrent-ruby-edge-0.6.0 lib/concurrent-ruby-edge/concurrent/channel/selector/after_clause.rb
concurrent-ruby-edge-0.6.0.pre1 lib/concurrent-ruby-edge/concurrent/channel/selector/after_clause.rb
concurrent-ruby-edge-0.5.0 lib-edge/concurrent/channel/selector/after_clause.rb
concurrent-ruby-edge-0.4.1 lib-edge/concurrent/channel/selector/after_clause.rb
concurrent-ruby-edge-0.4.0.pre2 lib-edge/concurrent/channel/selector/after_clause.rb
concurrent-ruby-edge-0.4.0.pre1 lib-edge/concurrent/channel/selector/after_clause.rb
concurrent-ruby-edge-0.2.4 lib/concurrent/channel/selector/after_clause.rb
concurrent-ruby-edge-0.3.1 lib/concurrent/channel/selector/after_clause.rb
concurrent-ruby-edge-0.3.0 lib/concurrent/channel/selector/after_clause.rb
concurrent-ruby-edge-0.2.3 lib/concurrent/channel/selector/after_clause.rb
concurrent-ruby-edge-0.2.3.pre3 lib/concurrent/channel/selector/after_clause.rb
concurrent-ruby-edge-0.2.2 lib/concurrent/channel/selector/after_clause.rb
concurrent-ruby-edge-0.2.1 lib/concurrent/channel/selector/after_clause.rb
concurrent-ruby-edge-0.2.0 lib/concurrent/channel/selector/after_clause.rb
concurrent-ruby-edge-0.2.0.pre5 lib/concurrent/channel/selector/after_clause.rb
concurrent-ruby-edge-0.2.0.pre4 lib/concurrent/channel/selector/after_clause.rb
concurrent-ruby-edge-0.2.0.pre3 lib/concurrent/channel/selector/after_clause.rb