Class: Rinda::TupleSpaceProxy::Port

Inherits:
Object
  • Object
show all
Defined in:
lib/rinda/rinda.rb

Overview

A Port ensures that a moved tuple arrives properly at its destination and does not get lost.

See bugs.ruby-lang.org/issues/8125

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePort

Returns a new instance of Port.



231
232
233
234
# File 'lib/rinda/rinda.rb', line 231

def initialize
  @open = true
  @value = nil
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value



217
218
219
# File 'lib/rinda/rinda.rb', line 217

def value
  @value
end

Class Method Details

.deliverObject



219
220
221
222
223
224
225
226
227
228
229
# File 'lib/rinda/rinda.rb', line 219

def self.deliver
  port = new

  begin
    yield(port)
  ensure
    port.close
  end

  port.value
end

Instance Method Details

#closeObject

Don’t let the DRb thread push to it when remote sends tuple



239
240
241
# File 'lib/rinda/rinda.rb', line 239

def close
  @open = false
end

#push(value) ⇒ Object

Stores value and ensure it does not get marshaled multiple times.



246
247
248
249
250
251
252
# File 'lib/rinda/rinda.rb', line 246

def push value
  raise 'port closed' unless @open

  @value = value

  nil # avoid Marshal
end