Module: Concurrent::Promises::AbstractEventFuture::ThrottleIntegration — Concurrent Ruby

# Module: Concurrent::Promises::AbstractEventFuture::ThrottleIntegration

Included in:
  Concurrent::Promises::AbstractEventFuture

Defined in:
  lib-edge/concurrent/edge/throttle.rb

## Instance Method Summary collapse

- #chain_throttled_by(throttle, *args, &block) ⇒ Future, Event

  Behaves as #chain but the it is throttled.

- #throttled_by(throttle) {|a| ... } ⇒ Future, Event

## Instance Method Details

### #chain_throttled_by(throttle, *args, &block) ⇒ `Future`, `Event`

Behaves as Concurrent::Promises::AbstractEventFuture#chain but the it is throttled.

Returns:

- (`Future`, `Event`)

See Also:

- Concurrent::Promises::AbstractEventFuture#chain

    169
    170
    171
    # File 'lib-edge/concurrent/edge/throttle.rb', line 169

    def chain_throttled_by(throttle, *args, &block)
      throttled_by(throttle) { |trigger| trigger.chain(*args, &block) }
    end

### #throttled_by(throttle) {|a| ... } ⇒ `Future`, `Event`

Yield Parameters:

- a (`Future`) —

  trigger

Yield Returns:

- (`Future`, `Event`)

Returns:

- (`Future`, `Event`)

    161
    162
    163
    164
    # File 'lib-edge/concurrent/edge/throttle.rb', line 161

    def throttled_by(throttle, &throttled_futures)
      a_trigger = self & self.chain { throttle.trigger }.flat_event
      throttled_futures.call(a_trigger).on_resolution! { throttle.release }
    end