Class: FiberStream::RactorProducerGroup
- Inherits:
-
Object
- Object
- FiberStream::RactorProducerGroup
- Defined in:
- lib/fiber_stream/ractor_producer.rb,
sig/fiber_stream.rbs
Overview
Builder passed to Source.ractor_merge_producers.
Each producer call records one lazily started owned producer definition.
Registration validates producer block isolation and transfer policy but
does not create Ractor ports or start producer code.
Instance Method Summary collapse
- #definitions ⇒ Object
-
#initialize(default_transfer) ⇒ RactorProducerGroup
constructor
A new instance of RactorProducerGroup.
- #producer(*args, transfer: nil) {|producer, args| ... } ⇒ self
Constructor Details
#initialize(default_transfer) ⇒ RactorProducerGroup
Returns a new instance of RactorProducerGroup.
147 148 149 150 |
# File 'lib/fiber_stream/ractor_producer.rb', line 147 def initialize(default_transfer) @default_transfer = default_transfer @definitions = [] end |
Instance Method Details
#definitions ⇒ Object
163 164 165 |
# File 'lib/fiber_stream/ractor_producer.rb', line 163 def definitions @definitions.dup.freeze end |
#producer(*args, transfer: nil) {|producer, args| ... } ⇒ self
152 153 154 155 156 157 158 159 160 161 |
# File 'lib/fiber_stream/ractor_producer.rb', line 152 def producer(*args, transfer: nil, &block) raise ArgumentError, "missing block" unless block unless transfer.nil? || [:copy, :move].include?(transfer) raise ArgumentError, "transfer must be :copy or :move" end raise TypeError, "block must be shareable" unless Ractor.shareable?(block) @definitions << Definition.new(args:, transfer: transfer || @default_transfer, block:) self end |