123456789_123456789_123456789_123456789_123456789_

Class: Concurrent::Throttle::ProxyExecutor

Constant Summary

Concern::Logging - Included

SEV_LABEL

Class Attribute Summary

Class Method Summary

Synchronization::Object - Inherited

.atomic_attribute?, .atomic_attributes,
.attr_atomic

Creates methods for reading and writing to a instance variable with volatile (Java) semantic as .attr_volatile does.

.attr_volatile

Creates methods for reading and writing (as attr_accessor does) to a instance variable with volatile (Java) semantic.

.ensure_safe_initialization_when_final_fields_are_present

For testing purposes, quite slow.

.new

Has to be called by children.

.safe_initialization!, .define_initialize_atomic_fields

Synchronization::AbstractObject - Inherited

Instance Attribute Summary

ExecutorService - Included

#can_overflow?

Does the task queue have a maximum size?

#serialized?

Does this executor guarantee serialization of its operations?

Instance Method Summary

ExecutorService - Included

#<<

Submit a task to the executor for asynchronous processing.

#post

Submit a task to the executor for asynchronous processing.

Concern::Logging - Included

#log

Logs through Concurrent.global_logger, it can be overridden by setting @logger.

Synchronization::Object - Inherited

Synchronization::Volatile - Included

Synchronization::AbstractObject - Inherited

Constructor Details

.new(throttle, executor) ⇒ ProxyExecutor

[ GitHub ]

  
# File 'lib/concurrent-ruby-edge/concurrent/edge/throttle.rb', line 192

def initialize(throttle, executor)
  super()
  @Throttle = throttle
  @Executor = executor
end

Instance Attribute Details

#can_overflow?Boolean (readonly)

[ GitHub ]

  
# File 'lib/concurrent-ruby-edge/concurrent/edge/throttle.rb', line 206

def can_overflow?
  @Executor.can_overflow?
end

#serialized?Boolean (readonly)

[ GitHub ]

  
# File 'lib/concurrent-ruby-edge/concurrent/edge/throttle.rb', line 210

def serialized?
  @Executor.serialized?
end

Instance Method Details

#inner_post(*arguments, &task) (private)

[ GitHub ]

  
# File 'lib/concurrent-ruby-edge/concurrent/edge/throttle.rb', line 216

def inner_post(*arguments, &task)
  @Executor.post(*arguments) do |*args|
    begin
      task.call(*args)
    ensure
      @Throttle.release
    end
  end
end

#post(*args, &task)

[ GitHub ]

  
# File 'lib/concurrent-ruby-edge/concurrent/edge/throttle.rb', line 198

def post(*args, &task)
  if (event = @Throttle.acquire_or_event)
    event.on_resolution! { inner_post(*args, &task) }
  else
    inner_post(*args, &task)
  end
end